From 2d88a83d8643f3e0284669f3716122f3088fcd8d Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Fri, 13 Dec 2024 16:00:45 +0100 Subject: [PATCH] review: simplify --- pkg/golinters/importas/importas.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/golinters/importas/importas.go b/pkg/golinters/importas/importas.go index c118ccb5a961..7986f152de3e 100644 --- a/pkg/golinters/importas/importas.go +++ b/pkg/golinters/importas/importas.go @@ -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 }