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:
Denis Isaev 2018-06-11 00:50:31 +03:00
parent 46088deacf
commit adb6be78bb
No known key found for this signature in database
GPG key ID: A36A0EC8E27A1A01
11 changed files with 232 additions and 87 deletions

View file

@ -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