Skip to content

Commit

Permalink
review: simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Dec 13, 2024
1 parent 588df60 commit 2d88a83
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/golinters/importas/importas.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ func New(settings *config.ImportAsSettings) *goanalysis.Linter {
uniqPackages[a.Pkg] = a
}

// skip the duplication check when the alias is a regular expression replacement pattern (ie. contains `$`).
// Skips the duplication check when:
// - the is alias is empty.
// - the alias is a regular expression replacement pattern (ie. contains `$`).
v, ok := uniqAliases[a.Alias]
if ok && !strings.Contains(a.Alias, "$") {
if ok && a.Alias != "" && !strings.Contains(a.Alias, "$") {
lintCtx.Log.Errorf("invalid configuration, multiple packages with the same alias: alias=%s packages=[%s,%s]", a.Alias, a.Pkg, v.Pkg)
} else if a.Alias != "" { // Ignore duplication for empty aliases.
} else {
uniqAliases[a.Alias] = a
}

Expand Down

0 comments on commit 2d88a83

Please # to comment.