mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
Fix #72: match more autogenerated files patterns.
We skip all issues from autogenerated files. Also reuse AST parsing for nolint and autogenerated exclude processors: decrease processing time on golang source code from 3s to 800ms.
This commit is contained in:
parent
46088deacf
commit
adb6be78bb
11 changed files with 232 additions and 87 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/golangci/golangci-lint/pkg/lint/astcache"
|
||||
"github.com/golangci/golangci-lint/pkg/result"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -20,7 +21,7 @@ func newNolintFileIssue(line int, fromLinter string) result.Issue {
|
|||
}
|
||||
|
||||
func TestNolint(t *testing.T) {
|
||||
p := NewNolint(token.NewFileSet())
|
||||
p := NewNolint(astcache.NewCache())
|
||||
|
||||
// test inline comments
|
||||
processAssertEmpty(t, p, newNolintFileIssue(3, "gofmt"))
|
||||
|
@ -76,26 +77,6 @@ func TestNolint(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestNoIssuesInAutogeneratedFiles(t *testing.T) {
|
||||
files := []string{
|
||||
"nolint_autogenerated.go",
|
||||
"nolint_autogenerated_alt_hdr.go",
|
||||
"nolint_autogenerated_alt_hdr2.go",
|
||||
}
|
||||
for _, file := range files {
|
||||
t.Run(file, func(t *testing.T) {
|
||||
i := result.Issue{
|
||||
Pos: token.Position{
|
||||
Filename: filepath.Join("testdata", file),
|
||||
Line: 4,
|
||||
},
|
||||
}
|
||||
p := NewNolint(token.NewFileSet())
|
||||
processAssertEmpty(t, p, i)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIgnoredRangeMatches(t *testing.T) {
|
||||
var testcases = []struct {
|
||||
doc string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue