lll: skip go command (#3572)

Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com>
This commit is contained in:
black-06 2023-02-22 09:13:49 +08:00 committed by GitHub
parent b673c5c1af
commit 610a2bd199
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -19,6 +19,8 @@ import (
const lllName = "lll"
const goCommentDirectivePrefix = "//go:"
//nolint:dupl
func NewLLL(settings *config.LllSettings) *goanalysis.Linter {
var mu sync.Mutex
@ -94,6 +96,10 @@ func getLLLIssuesForFile(filename string, maxLineLen int, tabSpaces string) ([]r
line := scanner.Text()
line = strings.ReplaceAll(line, "\t", tabSpaces)
if strings.HasPrefix(line, goCommentDirectivePrefix) {
continue
}
if strings.HasPrefix(line, "import") {
multiImportEnabled = strings.HasSuffix(line, "(")
continue

13
test/testdata/lll.go vendored
View File

@ -2,6 +2,19 @@
//golangcitest:config_path testdata/configs/lll.yml
package testdata
import (
_ "unsafe"
)
func Lll() {
// In my experience, long lines are the lines with comments, not the code. So this is a long comment // want "line is 137 characters"
}
//go:generate mockgen -source lll.go -destination a_verylong_generate_mock_my_lll_interface.go --package testdata -self_package github.com/golangci/golangci-lint/test/testdata
type MyLllInterface interface {
}
//go:linkname VeryLongNameForTestAndLinkNameFunction github.com/golangci/golangci-lint/test/testdata.VeryLongNameForTestAndLinkedNameFunction
func VeryLongNameForTestAndLinkNameFunction()
func VeryLongNameForTestAndLinkedNameFunction() {}