@@ -32,13 +32,12 @@ var (
3232 isGoCriticDebug = logutils .HaveDebugTag (logutils .DebugKeyGoCritic )
3333)
3434
35- func NewGoCritic (settings * config.GoCriticSettings , cfg * config. Config ) * goanalysis.Linter {
35+ func NewGoCritic (settings * config.GoCriticSettings ) * goanalysis.Linter {
3636 var mu sync.Mutex
3737 var resIssues []goanalysis.Issue
3838
3939 wrapper := & goCriticWrapper {
40- getConfigDir : cfg .GetConfigDir , // Config directory is filled after calling this constructor.
41- sizes : types .SizesFor ("gc" , runtime .GOARCH ),
40+ sizes : types .SizesFor ("gc" , runtime .GOARCH ),
4241 }
4342
4443 analyzer := & analysis.Analyzer {
@@ -71,7 +70,9 @@ Dynamic rules are written declaratively with AST patterns, filters, report messa
7170 nil ,
7271 ).
7372 WithContextSetter (func (context * linter.Context ) {
74- wrapper .init (settings , context .Log )
73+ wrapper .configDir = context .Cfg .GetConfigDir ()
74+
75+ wrapper .init (context .Log , settings )
7576 }).
7677 WithIssuesReporter (func (* linter.Context ) []goanalysis.Issue {
7778 return resIssues
@@ -81,12 +82,12 @@ Dynamic rules are written declaratively with AST patterns, filters, report messa
8182
8283type goCriticWrapper struct {
8384 settingsWrapper * goCriticSettingsWrapper
84- getConfigDir func () string
85+ configDir string
8586 sizes types.Sizes
8687 once sync.Once
8788}
8889
89- func (w * goCriticWrapper ) init (settings * config. GoCriticSettings , logger logutils. Log ) {
90+ func (w * goCriticWrapper ) init (logger logutils. Log , settings * config. GoCriticSettings ) {
9091 if settings == nil {
9192 return
9293 }
@@ -206,7 +207,7 @@ func (w *goCriticWrapper) normalizeCheckerParamsValue(p any) any {
206207 return rv .Bool ()
207208 case reflect .String :
208209 // Perform variable substitution.
209- return strings .ReplaceAll (rv .String (), "${configDir}" , w .getConfigDir () )
210+ return strings .ReplaceAll (rv .String (), "${configDir}" , w .configDir )
210211 default :
211212 return p
212213 }
0 commit comments