Skip to content

Commit

Permalink
remove regexps and fix multiImport condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ibez92 committed Oct 10, 2022
1 parent 6bece11 commit 9ad980b
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions pkg/golinters/lll.go
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"go/token"
"os"
"regexp"
"strings"
"sync"
"unicode/utf8"
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 9ad980b

Please sign in to comment.