@@ -48,8 +48,9 @@ Dynamic rules are written declaratively with AST patterns, filters, report messa
48
48
}
49
49
50
50
linterCtx .SetPackageInfo (pass .TypesInfo , pass .Pkg )
51
- var res []goanalysis.Issue
52
51
pkgIssues := runGocriticOnPackage (linterCtx , enabledCheckers , pass .Files )
52
+ res := make ([]goanalysis.Issue , 0 , len (pkgIssues ))
53
+
53
54
for i := range pkgIssues {
54
55
res = append (res , goanalysis .NewIssue (& pkgIssues [i ], pass ))
55
56
}
@@ -179,11 +180,23 @@ func runGocriticOnFile(ctx *gocriticlinter.Context, f *ast.File, checkers []*goc
179
180
// as read-only structure, so no copying is required.
180
181
for _ , warn := range c .Check (f ) {
181
182
pos := ctx .FileSet .Position (warn .Node .Pos ())
182
- res = append ( res , result.Issue {
183
+ issue := result.Issue {
183
184
Pos : pos ,
184
185
Text : fmt .Sprintf ("%s: %s" , c .Info .Name , warn .Text ),
185
186
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 )
187
200
}
188
201
}
189
202
0 commit comments