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:
Mateusz Gozdek 2020-11-01 21:31:15 +01:00 committed by GitHub
parent 7a1ae965d1
commit 9ff0f31ed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}