pkg/lint/lintersdb: report all unknown linters at once (#1477)
Otherwise, if one configures multiple invalid linters, or jumps between the versions, it is annoying to get same error with different value N times. Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
This commit is contained in:
parent
7a1ae965d1
commit
9ff0f31ed7
@ -20,12 +20,20 @@ func NewValidator(m *Manager) *Validator {
|
||||
func (v Validator) validateLintersNames(cfg *config.Linters) error {
|
||||
allNames := append([]string{}, cfg.Enable...)
|
||||
allNames = append(allNames, cfg.Disable...)
|
||||
|
||||
unknownNames := []string{}
|
||||
|
||||
for _, name := range allNames {
|
||||
if v.m.GetLinterConfigs(name) == nil {
|
||||
return fmt.Errorf("no such linter %v, run 'golangci-lint linters' to see the list of supported linters", name)
|
||||
unknownNames = append(unknownNames, name)
|
||||
}
|
||||
}
|
||||
|
||||
if len(unknownNames) > 0 {
|
||||
return fmt.Errorf("unknown linters: '%v', run 'golangci-lint linters' to see the list of supported linters",
|
||||
strings.Join(unknownNames, ","))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user