From 69144471caacd28ea63e7c9bce910ce43f96e351 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Tue, 19 Mar 2024 06:43:24 +0100 Subject: [PATCH] govet: fix check-shadowing (#4534) --- pkg/golinters/govet.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/golinters/govet.go b/pkg/golinters/govet.go index 4cf37d26b13e..504ed8a7525b 100644 --- a/pkg/golinters/govet.go +++ b/pkg/golinters/govet.go @@ -166,11 +166,6 @@ func analyzersFromConfig(settings *config.GovetSettings) []*analysis.Analyzer { return defaultAnalyzers } - if settings.CheckShadowing { - // Keeping for backward compatibility. - settings.Enable = append(settings.Enable, shadow.Analyzer.Name) - } - var enabledAnalyzers []*analysis.Analyzer for _, a := range allAnalyzers { if isAnalyzerEnabled(a.Name, settings, defaultAnalyzers) { @@ -189,6 +184,11 @@ func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers return false } + // Keeping for backward compatibility. + if cfg.CheckShadowing && name == shadow.Analyzer.Name { + return true + } + switch { case cfg.EnableAll: return !slices.Contains(cfg.Disable, name)