mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
dev: enable errorlint linter (#4292)
This commit is contained in:
parent
0264eaa5c7
commit
85fb5a2493
14 changed files with 36 additions and 31 deletions
|
@ -139,16 +139,16 @@ type BaseRule struct {
|
|||
|
||||
func (b *BaseRule) Validate(minConditionsCount int) error {
|
||||
if err := validateOptionalRegex(b.Path); err != nil {
|
||||
return fmt.Errorf("invalid path regex: %v", err)
|
||||
return fmt.Errorf("invalid path regex: %w", err)
|
||||
}
|
||||
if err := validateOptionalRegex(b.PathExcept); err != nil {
|
||||
return fmt.Errorf("invalid path-except regex: %v", err)
|
||||
return fmt.Errorf("invalid path-except regex: %w", err)
|
||||
}
|
||||
if err := validateOptionalRegex(b.Text); err != nil {
|
||||
return fmt.Errorf("invalid text regex: %v", err)
|
||||
return fmt.Errorf("invalid text regex: %w", err)
|
||||
}
|
||||
if err := validateOptionalRegex(b.Source); err != nil {
|
||||
return fmt.Errorf("invalid source regex: %v", err)
|
||||
return fmt.Errorf("invalid source regex: %w", err)
|
||||
}
|
||||
nonBlank := 0
|
||||
if len(b.Linters) > 0 {
|
||||
|
|
|
@ -38,11 +38,11 @@ func (r *FileReader) Read() error {
|
|||
|
||||
configFile, err := r.parseConfigOption()
|
||||
if err != nil {
|
||||
if err == errConfigDisabled {
|
||||
if errors.Is(err, errConfigDisabled) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("can't parse --config option: %s", err)
|
||||
return fmt.Errorf("can't parse --config option: %w", err)
|
||||
}
|
||||
|
||||
if configFile != "" {
|
||||
|
@ -65,7 +65,7 @@ func (r *FileReader) parseConfig() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("can't read viper config: %s", err)
|
||||
return fmt.Errorf("can't read viper config: %w", err)
|
||||
}
|
||||
|
||||
usedConfigFile := viper.ConfigFileUsed()
|
||||
|
@ -100,11 +100,11 @@ func (r *FileReader) parseConfig() error {
|
|||
// Needed for forbidigo.
|
||||
mapstructure.TextUnmarshallerHookFunc(),
|
||||
))); err != nil {
|
||||
return fmt.Errorf("can't unmarshal config by viper: %s", err)
|
||||
return fmt.Errorf("can't unmarshal config by viper: %w", err)
|
||||
}
|
||||
|
||||
if err := r.validateConfig(); err != nil {
|
||||
return fmt.Errorf("can't validate config: %s", err)
|
||||
return fmt.Errorf("can't validate config: %w", err)
|
||||
}
|
||||
|
||||
if r.cfg.InternalTest { // just for testing purposes: to detect config file usage
|
||||
|
@ -138,7 +138,7 @@ func (r *FileReader) validateConfig() error {
|
|||
}
|
||||
for i, rule := range c.Issues.ExcludeRules {
|
||||
if err := rule.Validate(); err != nil {
|
||||
return fmt.Errorf("error in exclude rule #%d: %v", i, err)
|
||||
return fmt.Errorf("error in exclude rule #%d: %w", i, err)
|
||||
}
|
||||
}
|
||||
if len(c.Severity.Rules) > 0 && c.Severity.Default == "" {
|
||||
|
@ -146,11 +146,11 @@ func (r *FileReader) validateConfig() error {
|
|||
}
|
||||
for i, rule := range c.Severity.Rules {
|
||||
if err := rule.Validate(); err != nil {
|
||||
return fmt.Errorf("error in severity rule #%d: %v", i, err)
|
||||
return fmt.Errorf("error in severity rule #%d: %w", i, err)
|
||||
}
|
||||
}
|
||||
if err := c.LintersSettings.Govet.Validate(); err != nil {
|
||||
return fmt.Errorf("error in govet config: %v", err)
|
||||
return fmt.Errorf("error in govet config: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue