@@ -211,6 +211,17 @@ func (e *Executor) runAnalysis(ctx context.Context, args []string) (<-chan resul
211
211
return nil , err
212
212
}
213
213
214
+ for _ , lc := range lintersdb .GetAllSupportedLinterConfigs () {
215
+ isEnabled := false
216
+ for _ , linter := range linters {
217
+ if linter .Linter .Name () == lc .Linter .Name () {
218
+ isEnabled = true
219
+ break
220
+ }
221
+ }
222
+ e .reportData .AddLinter (lc .Linter .Name (), isEnabled , lc .EnabledByDefault )
223
+ }
224
+
214
225
lintCtx , err := lint .LoadContext (ctx , linters , e .cfg , e .log .Child ("load" ))
215
226
if err != nil {
216
227
return nil , err
@@ -251,11 +262,30 @@ func (e *Executor) runAndPrint(ctx context.Context, args []string) error {
251
262
return err
252
263
}
253
264
265
+ p , err := e .createPrinter ()
266
+ if err != nil {
267
+ return err
268
+ }
269
+
270
+ gotAnyIssues , err := p .Print (ctx , issues )
271
+ if err != nil {
272
+ return fmt .Errorf ("can't print %d issues: %s" , len (issues ), err )
273
+ }
274
+
275
+ if gotAnyIssues {
276
+ e .exitCode = e .cfg .Run .ExitCodeIfIssuesFound
277
+ return nil
278
+ }
279
+
280
+ return nil
281
+ }
282
+
283
+ func (e * Executor ) createPrinter () (printers.Printer , error ) {
254
284
var p printers.Printer
255
285
format := e .cfg .Output .Format
256
286
switch format {
257
287
case config .OutFormatJSON :
258
- p = printers .NewJSON ()
288
+ p = printers .NewJSON (& e . reportData )
259
289
case config .OutFormatColoredLineNumber , config .OutFormatLineNumber :
260
290
p = printers .NewText (e .cfg .Output .PrintIssuedLine ,
261
291
format == config .OutFormatColoredLineNumber , e .cfg .Output .PrintLinterName , e .cfg .Run .Silent ,
@@ -266,20 +296,10 @@ func (e *Executor) runAndPrint(ctx context.Context, args []string) error {
266
296
case config .OutFormatCheckstyle :
267
297
p = printers .NewCheckstyle ()
268
298
default :
269
- return fmt .Errorf ("unknown output format %s" , format )
299
+ return nil , fmt .Errorf ("unknown output format %s" , format )
270
300
}
271
301
272
- gotAnyIssues , err := p .Print (ctx , issues )
273
- if err != nil {
274
- return fmt .Errorf ("can't print %d issues: %s" , len (issues ), err )
275
- }
276
-
277
- if gotAnyIssues {
278
- e .exitCode = e .cfg .Run .ExitCodeIfIssuesFound
279
- return nil
280
- }
281
-
282
- return nil
302
+ return p , nil
283
303
}
284
304
285
305
func (e * Executor ) executeRun (cmd * cobra.Command , args []string ) {
0 commit comments