Skip to content

Commit 4d36780

Browse files
committed
Support disable rule when enable-all is true
Similar to the behavior of command line flags: enable-all to enable existing linters then disable unwanted ones. But for vet rules.
1 parent 76a82c6 commit 4d36780

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pkg/golinters/govet.go

Lines changed: 5 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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)