Skip to content

Commit 9ea1afc

Browse files
Actually use IgnoreTests from the API. (#18)
Because the API took a list of `*File`s, it didn't actually skip tests as ParseTree did. This checks the name of each file before visiting its AST.
1 parent 1ab85de commit 9ea1afc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

api.go

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package goconst
33
import (
44
"go/ast"
55
"go/token"
6+
"strings"
67
)
78

89
type Issue struct {
@@ -38,6 +39,11 @@ func Run(files []*ast.File, fset *token.FileSet, cfg *Config) ([]Issue, error) {
3839
)
3940
var issues []Issue
4041
for _, f := range files {
42+
if p.ignoreTests {
43+
if filename := fset.Position(f.Pos()).Filename; strings.HasSuffix(filename, testSuffix) {
44+
continue
45+
}
46+
}
4147
ast.Walk(&treeVisitor{
4248
fileSet: fset,
4349
packageName: "",

0 commit comments

Comments
 (0)