@@ -48,8 +48,9 @@ Dynamic rules are written declaratively with AST patterns, filters, report messa
4848 }
4949
5050 linterCtx .SetPackageInfo (pass .TypesInfo , pass .Pkg )
51- var res []goanalysis.Issue
5251 pkgIssues := runGocriticOnPackage (linterCtx , enabledCheckers , pass .Files )
52+ res := make ([]goanalysis.Issue , 0 , len (pkgIssues ))
53+
5354 for i := range pkgIssues {
5455 res = append (res , goanalysis .NewIssue (& pkgIssues [i ], pass ))
5556 }
@@ -179,11 +180,23 @@ func runGocriticOnFile(ctx *gocriticlinter.Context, f *ast.File, checkers []*goc
179180 // as read-only structure, so no copying is required.
180181 for _ , warn := range c .Check (f ) {
181182 pos := ctx .FileSet .Position (warn .Node .Pos ())
182- res = append ( res , result.Issue {
183+ issue := result.Issue {
183184 Pos : pos ,
184185 Text : fmt .Sprintf ("%s: %s" , c .Info .Name , warn .Text ),
185186 FromLinter : gocriticName ,
186- })
187+ }
188+
189+ if warn .HasQuickFix () {
190+ issue .Replacement = & result.Replacement {
191+ Inline : & result.InlineFix {
192+ StartCol : pos .Column - 1 ,
193+ Length : int (warn .Node .End () - warn .Node .Pos ()),
194+ NewString : string (warn .Suggestion .Replacement ),
195+ },
196+ }
197+ }
198+
199+ res = append (res , issue )
187200 }
188201 }
189202
0 commit comments