Skip to content

Commit 14eed91

Browse files
authored
Merge pull request #989 from ferhatelmas/vet-rule-disable
vet: Support disable rule when enable-all is true
2 parents 76a82c6 + 4d36780 commit 14eed91

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pkg/golinters/govet.go

+5
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ var (
101101

102102
func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers []*analysis.Analyzer) bool {
103103
if cfg.EnableAll {
104+
for _, n := range cfg.Disable {
105+
if n == name {
106+
return false
107+
}
108+
}
104109
return true
105110
}
106111
// Raw for loops should be OK on small slice lengths.

pkg/golinters/govet_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func TestGovetAnalyzerIsEnabled(t *testing.T) {
7979
{Name: "bools", Enabled: false, Disable: []string{"bools"}},
8080
{Name: "unsafeptr", Enabled: true, Enable: []string{"unsafeptr"}},
8181
{Name: "shift", Enabled: true, EnableAll: true},
82+
{Name: "shadow", EnableAll: true, Disable: []string{"shadow"}, Enabled: false},
8283
} {
8384
cfg := &config.GovetSettings{
8485
Enable: tc.Enable,

0 commit comments

Comments
 (0)