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.
This commit is contained in:
		
							parent
							
								
									76a82c6ed1
								
							
						
					
					
						commit
						4d367808be
					
				| @ -101,6 +101,11 @@ var ( | |||||||
| 
 | 
 | ||||||
| func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers []*analysis.Analyzer) bool { | func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers []*analysis.Analyzer) bool { | ||||||
| 	if cfg.EnableAll { | 	if cfg.EnableAll { | ||||||
|  | 		for _, n := range cfg.Disable { | ||||||
|  | 			if n == name { | ||||||
|  | 				return false | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
| 		return true | 		return true | ||||||
| 	} | 	} | ||||||
| 	// Raw for loops should be OK on small slice lengths. | 	// Raw for loops should be OK on small slice lengths. | ||||||
|  | |||||||
| @ -79,6 +79,7 @@ func TestGovetAnalyzerIsEnabled(t *testing.T) { | |||||||
| 		{Name: "bools", Enabled: false, Disable: []string{"bools"}}, | 		{Name: "bools", Enabled: false, Disable: []string{"bools"}}, | ||||||
| 		{Name: "unsafeptr", Enabled: true, Enable: []string{"unsafeptr"}}, | 		{Name: "unsafeptr", Enabled: true, Enable: []string{"unsafeptr"}}, | ||||||
| 		{Name: "shift", Enabled: true, EnableAll: true}, | 		{Name: "shift", Enabled: true, EnableAll: true}, | ||||||
|  | 		{Name: "shadow", EnableAll: true, Disable: []string{"shadow"}, Enabled: false}, | ||||||
| 	} { | 	} { | ||||||
| 		cfg := &config.GovetSettings{ | 		cfg := &config.GovetSettings{ | ||||||
| 			Enable:     tc.Enable, | 			Enable:     tc.Enable, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 ferhat elmas
						ferhat elmas