Skip to content

Commit 0ed91bf

Browse files
committed
analysis: remove default excludes
1 parent e9a45b2 commit 0ed91bf

File tree

3 files changed

+10
-28
lines changed

3 files changed

+10
-28
lines changed

analysis.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ var (
4646
// DefaultMaxConcurrent is the default maximum concurrency to use when
4747
// analyzing files.
4848
DefaultMaxConcurrent = runtime.GOMAXPROCS(0) * 2
49-
50-
// DefaultExcludes are the default files to exclude when analyzing.
51-
DefaultExcludes = []string{
52-
"**/testdata/**", // Exclude testdata directories
53-
}
5449
)
5550

5651
// Config is the golicenser configuration.
@@ -96,9 +91,6 @@ func newAnalyzer(cfg Config) (*analyzer, error) {
9691
if cfg.CopyrightHeaderMatcher == "" {
9792
cfg.CopyrightHeaderMatcher = DefaultCopyrightHeaderMatcher
9893
}
99-
if cfg.Exclude == nil {
100-
cfg.Exclude = DefaultExcludes
101-
}
10294

10395
a := &analyzer{cfg: cfg}
10496

analysis_test.go

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ package golicenser
2222

2323
import (
2424
"path/filepath"
25-
"reflect"
2625
"testing"
2726
"time"
2827

@@ -47,7 +46,6 @@ func TestAnalyzer(t *testing.T) {
4746
Author: "Test",
4847
YearMode: YearModeThisYear,
4948
},
50-
Exclude: []string{},
5149
}
5250
a, err := NewAnalyzer(cfg)
5351
if err != nil {
@@ -97,7 +95,6 @@ func TestAnalyzer(t *testing.T) {
9795
Matcher: "Copyright \\(c\\) {{.year}} Joshua",
9896
YearMode: YearModeThisYear,
9997
},
100-
Exclude: []string{},
10198
}
10299
a, err := NewAnalyzer(cfg)
103100
if err != nil {
@@ -169,9 +166,6 @@ func TestNewAnalyzer(t *testing.T) {
169166
t.Errorf("CopyrightHeaderMatcher = %v, want %v",
170167
a.cfg.CopyrightHeaderMatcher, DefaultCopyrightHeaderMatcher)
171168
}
172-
if !reflect.DeepEqual(a.cfg.Exclude, DefaultExcludes) {
173-
t.Errorf("Exclude = %v, want %v", a.cfg.Exclude, DefaultExcludes)
174-
}
175169
},
176170
},
177171
{
@@ -188,27 +182,23 @@ func TestNewAnalyzer(t *testing.T) {
188182
Header: header,
189183
Exclude: []string{
190184
"/abc/*",
191-
"**/testdata/**",
192185
"", // empty strings should be ignored
193186
"/test/**",
194187
},
195188
},
196189
check: func(t *testing.T, a *analyzer) {
197190
t.Helper()
198191

199-
if l := len(a.excludes); l != 3 {
200-
t.Errorf("excludes len = %d, want 3", l)
192+
if l := len(a.excludes); l != 2 {
193+
t.Errorf("excludes len = %d, want 2", l)
201194
}
202195
tests := map[string]bool{
203-
"afile.go": false,
204-
"/subdir/test": false,
205-
"/abc/": true,
206-
"/abc/test": true,
207-
"/testdata/": true,
208-
"/testdata/abc": true,
209-
"/subdir/testdata/test": true,
210-
"/test/somefile": true,
211-
"/test/": true,
196+
"afile.go": false,
197+
"/subdir/test": false,
198+
"/abc/": true,
199+
"/abc/test": true,
200+
"/test/somefile": true,
201+
"/test/": true,
212202
}
213203
for path, want := range tests {
214204
var excluded bool
@@ -279,7 +269,7 @@ func TestNewAnalyzer(t *testing.T) {
279269
Header: header,
280270
Exclude: []string{
281271
"/abc/*",
282-
"**/testdata/*{*",
272+
"**/test/*{*",
283273
},
284274
},
285275
wantErr: true,

cmd/golicenser/golicenser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func init() {
7272
"Year formatting mode (preserve, preserve-this-year-range, preserve-modified-range, this-year, last-modified, git-range, git-modified-years)")
7373
flagSet.StringVar(&commentStyleStr, "comment-style", golicenser.CommentStyle(0).String(),
7474
"Comment style (line, block)")
75-
flagSet.StringVar(&exclude, "exclude", strings.Join(golicenser.DefaultExcludes, ","),
75+
flagSet.StringVar(&exclude, "exclude", "",
7676
"Paths to exclude (doublestar or r!-prefixed regexp, comma-separated)")
7777
flagSet.IntVar(&maxConcurrent, "max-concurrent", golicenser.DefaultMaxConcurrent,
7878
"Maximum concurrent processes to use when processing files")

0 commit comments

Comments
 (0)