dev: rewrite linters Manager (#4419)

This commit is contained in:
Ludovic Fernandez 2024-03-02 21:43:28 +01:00 committed by GitHub
parent 26f8088b38
commit b14d05cdb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 1749 additions and 1825 deletions

View file

@ -1,5 +1,10 @@
package config
import (
"errors"
"fmt"
)
const severityRuleMinConditionsCount = 1
type Severity struct {
@ -8,6 +13,20 @@ type Severity struct {
Rules []SeverityRule `mapstructure:"rules"`
}
func (s *Severity) Validate() error {
if len(s.Rules) > 0 && s.Default == "" {
return errors.New("can't set severity rule option: no default severity defined")
}
for i, rule := range s.Rules {
if err := rule.Validate(); err != nil {
return fmt.Errorf("error in severity rule #%d: %w", i, err)
}
}
return nil
}
type SeverityRule struct {
BaseRule `mapstructure:",squash"`
Severity string