fix(config): validate rules when [extend] is used (#1592)

This commit is contained in:
Richard Gomez authored and GitHub committed 2025-10-16 10:54:59 -05:00
1 parent 87d96295d6
commit d22371873b
5 files changed
+38 -15

No files matched your search

+10 -8
View File
@@ -69,15 +69,17 @@ func (r *Rule) Validate() error {
// Ensure |id| is present.
if strings.TrimSpace(r.RuleID) == "" {
// Try to provide helpful context, since |id| is empty.
var context string
if r.Regex != nil {
context = ", regex: " + r.Regex.String()
} else if r.Path != nil {
context = ", path: " + r.Path.String()
} else if r.Description != "" {
context = ", description: " + r.Description
var sb strings.Builder
if r.Description != "" {
sb.WriteString(", description: " + r.Description)
}
return errors.New("rule |id| is missing or empty" + context)
if r.Regex != nil {
sb.WriteString(", regex: " + r.Regex.String())
}
if r.Path != nil {
sb.WriteString(", path: " + r.Path.String())
}
return errors.New("rule |id| is missing or empty" + sb.String())
}
// Ensure the rule actually matches something.