Skip to content

lll: skip go command #3572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/golinters/lll.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

const lllName = "lll"

const goCommentDirectivePrefix = "//go:"

//nolint:dupl
func NewLLL(settings *config.LllSettings) *goanalysis.Linter {
var mu sync.Mutex
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions test/testdata/lll.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}