Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23.0
toolchain go1.24.1

require (
github.com/gobwas/glob v0.2.3
github.com/gobwas/glob v1.0.0
golang.org/x/tools v0.31.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/gobwas/glob v1.0.0 h1:p+FKbLEIsK1yZ39/OINwFvqNb5oyPY4H8xcy6uYu8dg=
github.com/gobwas/glob v1.0.0/go.mod h1:oWCdo522i2P1n/hMXGNWs7yoV4wy/ciZuUIbvKj5rkc=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
Expand Down
6 changes: 3 additions & 3 deletions settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const (
type list struct {
listMode listMode
name string
files []glob.Glob
negFiles []glob.Glob
files []*glob.Pattern
negFiles []*glob.Pattern
allow []string
deny []string
suggestions []string
Expand Down Expand Up @@ -212,7 +212,7 @@ func (s linterSettings) whichLists(fileName string) []*list {
return matches
}

func strInGlobList(str string, globList []glob.Glob) bool {
func strInGlobList(str string, globList []*glob.Pattern) bool {
for _, g := range globList {
if g.Match(str) {
return true
Expand Down
40 changes: 22 additions & 18 deletions settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ type settingsCompileScenario struct {
expErr error
}

func cmpGlobPattern(a, b *glob.Pattern) bool {
return a.String() == b.String()
}

var (
listCompileScenarios = []*listCompileScenario{
{
Expand Down Expand Up @@ -56,7 +60,7 @@ var (
Allow: []string{"os"},
},
exp: &list{
files: []glob.Glob{
files: []*glob.Pattern{
glob.MustCompile("**/*.go", '/'),
},
allow: []string{"os"},
Expand All @@ -69,7 +73,7 @@ var (
Allow: []string{"os"},
},
exp: &list{
negFiles: []glob.Glob{
negFiles: []*glob.Pattern{
glob.MustCompile("**/*_test.go", '/'),
},
allow: []string{"os"},
Expand All @@ -82,10 +86,10 @@ var (
Allow: []string{"os"},
},
exp: &list{
files: []glob.Glob{
files: []*glob.Pattern{
glob.MustCompile("**/foo.go", '/'),
},
negFiles: []glob.Glob{
negFiles: []*glob.Pattern{
glob.MustCompile("**/bar.go", '/'),
},
allow: []string{"os"},
Expand Down Expand Up @@ -148,10 +152,10 @@ var (
},
},
exp: &list{
files: []glob.Glob{
files: []*glob.Pattern{
glob.MustCompile("**/*.go", '/'),
},
negFiles: []glob.Glob{
negFiles: []*glob.Pattern{
glob.MustCompile("**/*_test.go", '/'),
},
allow: []string{"os"},
Expand Down Expand Up @@ -240,7 +244,7 @@ var (
exp: []*list{
{
name: "Main",
files: []glob.Glob{
files: []*glob.Pattern{
glob.MustCompile("**/*.go", '/'),
},
allow: []string{"FIND ME", "FIND ME TOO"},
Expand All @@ -262,14 +266,14 @@ var (
exp: []*list{
{
name: "Main",
files: []glob.Glob{
files: []*glob.Pattern{
glob.MustCompile("**/*.go", '/'),
},
allow: []string{"os"},
},
{
name: "Test",
files: []glob.Glob{
files: []*glob.Pattern{
glob.MustCompile("**/*_test.go", '/'),
},
allow: []string{"os"},
Expand All @@ -294,7 +298,7 @@ func testListCompile(s *listCompileScenario) func(*testing.T) {
if err != nil {
t.Fatal("not expecting an error")
}
diff := cmp.Diff(s.exp, act, cmp.AllowUnexported(list{}))
diff := cmp.Diff(s.exp, act, cmp.AllowUnexported(list{}), cmp.Comparer(cmpGlobPattern))
if diff != "" {
t.Errorf("compiled list is not what was expected\n%s", diff)
}
Expand All @@ -316,7 +320,7 @@ func testSettingsCompile(s *settingsCompileScenario) func(*testing.T) {
if err != nil {
t.Fatal("not expecting an error")
}
diff := cmp.Diff(s.exp, act, cmp.AllowUnexported(list{}))
diff := cmp.Diff(s.exp, act, cmp.AllowUnexported(list{}), cmp.Comparer(cmpGlobPattern))
if diff != "" {
t.Errorf("compiled settings is not what was expected\n%s", diff)
}
Expand Down Expand Up @@ -365,7 +369,7 @@ var (
"willd.io/normal/package",
}

globList = []glob.Glob{
globList = []*glob.Pattern{
glob.MustCompile("some/*/a", '/'),
glob.MustCompile("some/**/a", '/'),
}
Expand Down Expand Up @@ -482,7 +486,7 @@ var listFileMatchScenarios = []*listFileMatchScenario{
{
name: "Empty allow matches anything not in deny",
setup: &list{
negFiles: []glob.Glob{
negFiles: []*glob.Pattern{
glob.MustCompile("**/*_test.go", '/'),
},
},
Expand All @@ -507,7 +511,7 @@ var listFileMatchScenarios = []*listFileMatchScenario{
{
name: "Empty deny only matches what is in allowed",
setup: &list{
files: []glob.Glob{
files: []*glob.Pattern{
glob.MustCompile("**/*_test.go", '/'),
},
},
Expand All @@ -532,10 +536,10 @@ var listFileMatchScenarios = []*listFileMatchScenario{
{
name: "Both only allows what is in allow and not in deny",
setup: &list{
files: []glob.Glob{
files: []*glob.Pattern{
glob.MustCompile("**/*.go", '/'),
},
negFiles: []glob.Glob{
negFiles: []*glob.Pattern{
glob.MustCompile("**/*_test.go", '/'),
},
},
Expand Down Expand Up @@ -931,13 +935,13 @@ type linterSettingsWhichListsScenario struct {
var linterSettingsWhichListsSetup = linterSettings{
{
name: "Main",
files: []glob.Glob{
files: []*glob.Pattern{
glob.MustCompile("**/*.go", '/'),
},
},
{
name: "Test",
files: []glob.Glob{
files: []*glob.Pattern{
glob.MustCompile("**/*_test.go", '/'),
},
},
Expand Down