Skip to content

Commit a0c9ad2

Browse files
committed
prefer Glob over Files in Patterns() instead of merging both
When both glob: and files: are set on the same override or kind-assignment entry, Patterns() previously returned the union of both, silently broadening the match set. Now Glob takes precedence and Files is used only when Glob is absent, which matches the documented deprecation semantics. https://claude.ai/code/session_01NEgDS5N2TCk6KyYfKxrJP8
1 parent 797bd64 commit a0c9ad2

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

internal/config/config.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,14 @@ type Override struct {
9292
Categories map[string]bool `yaml:"categories"`
9393
}
9494

95-
// Patterns returns the effective set of glob patterns for the override,
96-
// combining the canonical Glob field with the deprecated Files alias.
95+
// Patterns returns the effective set of glob patterns for the override.
96+
// When Glob is set it takes precedence; Files is used only when Glob is
97+
// absent (backward compatibility with the deprecated files: key).
9798
func (o Override) Patterns() []string {
98-
return append(o.Glob, o.Files...)
99+
if len(o.Glob) > 0 {
100+
return o.Glob
101+
}
102+
return o.Files
99103
}
100104

101105
// KindBody is a named bundle of rule settings. It has the same shape as
@@ -117,10 +121,14 @@ type KindAssignmentEntry struct {
117121
Kinds []string `yaml:"kinds"`
118122
}
119123

120-
// Patterns returns the effective set of glob patterns for the entry,
121-
// combining the canonical Glob field with the deprecated Files alias.
124+
// Patterns returns the effective set of glob patterns for the entry.
125+
// When Glob is set it takes precedence; Files is used only when Glob is
126+
// absent (backward compatibility with the deprecated files: key).
122127
func (e KindAssignmentEntry) Patterns() []string {
123-
return append(e.Glob, e.Files...)
128+
if len(e.Glob) > 0 {
129+
return e.Glob
130+
}
131+
return e.Files
124132
}
125133

126134
// RuleCfg is a YAML union: can be bool (enable/disable) or map[string]any (settings).

0 commit comments

Comments
 (0)