Skip to content

Commit bdc29dd

Browse files
feat: throw error if duplicate rules in enabled rules
1 parent 9173967 commit bdc29dd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

config/config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ func Validate(conf *lint.Config) []error {
9191
}
9292
}
9393

94+
// Check for duplicate rules
95+
ruleSeen := make(map[string]struct{}, len(conf.Rules))
96+
for _, ruleName := range conf.Rules {
97+
if _, exists := ruleSeen[ruleName]; exists {
98+
errs = append(errs, fmt.Errorf("duplicate rule '%s' in rules list", ruleName))
99+
} else {
100+
ruleSeen[ruleName] = struct{}{}
101+
}
102+
}
103+
94104
for ruleName, ruleSetting := range conf.Settings {
95105
// Check if rule is registered
96106
ruleData, ok := registry.GetRule(ruleName)

0 commit comments

Comments
 (0)