diff --git a/pkg/golinters/lll.go b/pkg/golinters/lll.go index 55979cdfd62f..de2c56825fa8 100644 --- a/pkg/golinters/lll.go +++ b/pkg/golinters/lll.go @@ -5,7 +5,6 @@ import ( "fmt" "go/token" "os" - "regexp" "strings" "sync" "unicode/utf8" @@ -20,9 +19,6 @@ import ( const lllName = "lll" -var lllMultiImportStartRegexp = regexp.MustCompile(`^import \($`) -var lllSingleImportRegexp = regexp.MustCompile(`^import \".+\"$`) - //nolint:dupl func NewLLL(settings *config.LllSettings) *goanalysis.Linter { var mu sync.Mutex @@ -97,19 +93,16 @@ func getLLLIssuesForFile(filename string, maxLineLen int, tabSpaces string) ([]r line = strings.ReplaceAll(line, "\t", tabSpaces) // Skips imports if !importsEnded { - if lllSingleImportRegexp.MatchString(line) { - lineNumber++ - continue - } + if strings.HasPrefix(line, "import") { + if strings.HasSuffix(line, "(") { + multiImportEnabled = true + } - if lllMultiImportStartRegexp.MatchString(line) { - multiImportEnabled = true lineNumber++ continue } - if multiImportEnabled && line == ")" { - importsEnded = true + if multiImportEnabled && line != ")" { lineNumber++ continue }