File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ func (w *goCriticWrapper) init(logger logutils.Log, settings *config.GoCriticSet
8888
8989 settingsWrapper := newSettingsWrapper (settings , logger )
9090 settingsWrapper .InferEnabledChecks ()
91+
9192 // Validate must be after InferEnabledChecks, not before.
9293 // Because it uses gathered information about tags set and finally enabled checks.
9394 if err := settingsWrapper .Validate (); err != nil {
@@ -113,7 +114,17 @@ func (w *goCriticWrapper) run(pass *analysis.Pass) error {
113114
114115 linterCtx .SetPackageInfo (pass .TypesInfo , pass .Pkg )
115116
117+ needFileInfo := slices .ContainsFunc (enabledCheckers , func (c * gocriticlinter.Checker ) bool {
118+ // Related to https://github.com/go-critic/go-critic/blob/440ff466685b41e67d231a1c4a8f5e093374ee93/checkers/importShadow_checker.go#L23
119+ return strings .EqualFold (c .Info .Name , "importShadow" )
120+ })
121+
116122 for _ , f := range pass .Files {
123+ if needFileInfo {
124+ // Related to https://github.com/go-critic/go-critic/blob/440ff466685b41e67d231a1c4a8f5e093374ee93/checkers/importShadow_checker.go#L23
125+ linterCtx .SetFileInfo (f .Name .Name , f )
126+ }
127+
117128 runOnFile (pass , f , enabledCheckers )
118129 }
119130
You can’t perform that action at this time.
0 commit comments