Skip to content

Commit 98ad5e9

Browse files
committed
Ignore blank excludes, fixes #23
1 parent b8a99be commit 98ad5e9

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

analyzer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ func run(pass *analysis.Pass) (interface{}, error) {
102102
c := c
103103
i.Preorder(c.NodeFilter(), func(node ast.Node) {
104104
for _, exclude := range conf.IgnoredFiles {
105+
if exclude.String() == "" {
106+
continue
107+
}
105108
if exclude.MatchString(pass.Fset.Position(node.Pos()).Filename) {
106109
return
107110
}

analyzer_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,19 @@ func TestCanIgnoreFiles(t *testing.T) {
8484

8585
analysistest.Run(t, testdata, analyzer, "ignored/files")
8686
}
87+
88+
func TestCanIgnoreFilesWithBlankExcludesOption(t *testing.T) {
89+
testdata := analysistest.TestData()
90+
91+
options := flag.NewFlagSet("", flag.ExitOnError)
92+
options.String("checks", "argument", "")
93+
options.String("excludes", "", "")
94+
options.String("ignored-files", "ignored1,ignored2", "")
95+
options.String("ignored-functions", "", "")
96+
options.String("ignored-numbers", "", "")
97+
98+
analyzer := Analyzer
99+
analyzer.Flags = *options
100+
101+
analysistest.Run(t, testdata, analyzer, "ignored/files")
102+
}

0 commit comments

Comments
 (0)