@@ -211,6 +211,17 @@ func (e *Executor) runAnalysis(ctx context.Context, args []string) (<-chan resul
211211 return nil , err
212212 }
213213
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+
214225 lintCtx , err := lint .LoadContext (ctx , linters , e .cfg , e .log .Child ("load" ))
215226 if err != nil {
216227 return nil , err
@@ -251,11 +262,30 @@ func (e *Executor) runAndPrint(ctx context.Context, args []string) error {
251262 return err
252263 }
253264
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 ) {
254284 var p printers.Printer
255285 format := e .cfg .Output .Format
256286 switch format {
257287 case config .OutFormatJSON :
258- p = printers .NewJSON ()
288+ p = printers .NewJSON (& e . reportData )
259289 case config .OutFormatColoredLineNumber , config .OutFormatLineNumber :
260290 p = printers .NewText (e .cfg .Output .PrintIssuedLine ,
261291 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 {
266296 case config .OutFormatCheckstyle :
267297 p = printers .NewCheckstyle ()
268298 default :
269- return fmt .Errorf ("unknown output format %s" , format )
299+ return nil , fmt .Errorf ("unknown output format %s" , format )
270300 }
271301
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
283303}
284304
285305func (e * Executor ) executeRun (cmd * cobra.Command , args []string ) {
0 commit comments