Skip to content

Commit 9ad980b

Browse files
committed
remove regexps and fix multiImport condition
1 parent 6bece11 commit 9ad980b

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

pkg/golinters/lll.go

+5-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"go/token"
77
"os"
8-
"regexp"
98
"strings"
109
"sync"
1110
"unicode/utf8"
@@ -20,9 +19,6 @@ import (
2019

2120
const lllName = "lll"
2221

23-
var lllMultiImportStartRegexp = regexp.MustCompile(`^import \($`)
24-
var lllSingleImportRegexp = regexp.MustCompile(`^import \".+\"$`)
25-
2622
//nolint:dupl
2723
func NewLLL(settings *config.LllSettings) *goanalysis.Linter {
2824
var mu sync.Mutex
@@ -97,19 +93,16 @@ func getLLLIssuesForFile(filename string, maxLineLen int, tabSpaces string) ([]r
9793
line = strings.ReplaceAll(line, "\t", tabSpaces)
9894
// Skips imports
9995
if !importsEnded {
100-
if lllSingleImportRegexp.MatchString(line) {
101-
lineNumber++
102-
continue
103-
}
96+
if strings.HasPrefix(line, "import") {
97+
if strings.HasSuffix(line, "(") {
98+
multiImportEnabled = true
99+
}
104100

105-
if lllMultiImportStartRegexp.MatchString(line) {
106-
multiImportEnabled = true
107101
lineNumber++
108102
continue
109103
}
110104

111-
if multiImportEnabled && line == ")" {
112-
importsEnded = true
105+
if multiImportEnabled && line != ")" {
113106
lineNumber++
114107
continue
115108
}

0 commit comments

Comments
 (0)