Merge pull request #989 from ferhatelmas/vet-rule-disable

vet: Support disable rule when enable-all is true
This commit is contained in:
Aleksandr Razumov 2020-03-12 20:04:16 +03:00 committed by GitHub
commit 14eed91cc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -101,6 +101,11 @@ var (
func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers []*analysis.Analyzer) bool {
if cfg.EnableAll {
for _, n := range cfg.Disable {
if n == name {
return false
}
}
return true
}
// Raw for loops should be OK on small slice lengths.

View File

@ -79,6 +79,7 @@ func TestGovetAnalyzerIsEnabled(t *testing.T) {
{Name: "bools", Enabled: false, Disable: []string{"bools"}},
{Name: "unsafeptr", Enabled: true, Enable: []string{"unsafeptr"}},
{Name: "shift", Enabled: true, EnableAll: true},
{Name: "shadow", EnableAll: true, Disable: []string{"shadow"}, Enabled: false},
} {
cfg := &config.GovetSettings{
Enable: tc.Enable,