@@ -431,9 +431,7 @@ protected override void StopProcessing()
431
431
432
432
private void ProcessInput ( )
433
433
{
434
- var diagnosticRecords = RunAnalysis ( ) ;
435
- WriteToOutput ( diagnosticRecords ) ;
436
- totalDiagnosticCount += diagnosticRecords . Count ;
434
+ WriteToOutput ( RunAnalysis ( ) ) ;
437
435
}
438
436
439
437
private List < DiagnosticRecord > RunAnalysis ( )
@@ -461,56 +459,59 @@ private List<DiagnosticRecord> RunAnalysis()
461
459
return diagnostics ;
462
460
}
463
461
464
- private void WriteToOutput ( List < DiagnosticRecord > diagnosticRecords )
462
+ private void WriteToOutput ( IEnumerable < DiagnosticRecord > diagnosticRecords )
465
463
{
466
- foreach ( ILogger logger in ScriptAnalyzer . Instance . Loggers )
467
- {
468
- var errorCount = 0 ;
469
- var warningCount = 0 ;
470
- var infoCount = 0 ;
471
- var parseErrorCount = 0 ;
464
+ var errorCount = 0 ;
465
+ var warningCount = 0 ;
466
+ var infoCount = 0 ;
467
+ var parseErrorCount = 0 ;
472
468
473
- foreach ( DiagnosticRecord diagnostic in diagnosticRecords )
469
+ foreach ( DiagnosticRecord diagnostic in diagnosticRecords )
470
+ {
471
+ foreach ( ILogger logger in ScriptAnalyzer . Instance . Loggers )
474
472
{
475
473
logger . LogObject ( diagnostic , this ) ;
476
- switch ( diagnostic . Severity )
477
- {
478
- case DiagnosticSeverity . Information :
479
- infoCount ++ ;
480
- break ;
481
- case DiagnosticSeverity . Warning :
482
- warningCount ++ ;
483
- break ;
484
- case DiagnosticSeverity . Error :
485
- errorCount ++ ;
486
- break ;
487
- case DiagnosticSeverity . ParseError :
488
- parseErrorCount ++ ;
489
- break ;
490
- default :
491
- throw new ArgumentOutOfRangeException ( nameof ( diagnostic . Severity ) , $ "Severity '{ diagnostic . Severity } ' is unknown") ;
492
- }
493
474
}
494
475
495
- if ( ReportSummary . IsPresent )
476
+ totalDiagnosticCount ++ ;
477
+
478
+ switch ( diagnostic . Severity )
479
+ {
480
+ case DiagnosticSeverity . Information :
481
+ infoCount ++ ;
482
+ break ;
483
+ case DiagnosticSeverity . Warning :
484
+ warningCount ++ ;
485
+ break ;
486
+ case DiagnosticSeverity . Error :
487
+ errorCount ++ ;
488
+ break ;
489
+ case DiagnosticSeverity . ParseError :
490
+ parseErrorCount ++ ;
491
+ break ;
492
+ default :
493
+ throw new ArgumentOutOfRangeException ( nameof ( diagnostic . Severity ) , $ "Severity '{ diagnostic . Severity } ' is unknown") ;
494
+ }
495
+ }
496
+
497
+ if ( ReportSummary . IsPresent )
498
+ {
499
+ var numberOfRuleViolations = infoCount + warningCount + errorCount ;
500
+ if ( numberOfRuleViolations == 0 )
501
+ {
502
+ Host . UI . WriteLine ( "0 rule violations found." ) ;
503
+ }
504
+ else
496
505
{
497
- var numberOfRuleViolations = infoCount + warningCount + errorCount ;
498
- if ( numberOfRuleViolations == 0 )
506
+ var pluralS = numberOfRuleViolations > 1 ? "s" : string . Empty ;
507
+ var message = $ "{ numberOfRuleViolations } rule violation{ pluralS } found. Severity distribution: { DiagnosticSeverity . Error } = { errorCount } , { DiagnosticSeverity . Warning } = { warningCount } , { DiagnosticSeverity . Information } = { infoCount } ";
508
+ if ( warningCount + errorCount == 0 )
499
509
{
500
- Host . UI . WriteLine ( "0 rule violations found." ) ;
510
+ ConsoleHostHelper . DisplayMessageUsingSystemProperties ( Host , "WarningForegroundColor" , "WarningBackgroundColor" , message ) ;
501
511
}
502
512
else
503
513
{
504
- var pluralS = numberOfRuleViolations > 1 ? "s" : string . Empty ;
505
- var message = $ "{ numberOfRuleViolations } rule violation{ pluralS } found. Severity distribution: { DiagnosticSeverity . Error } = { errorCount } , { DiagnosticSeverity . Warning } = { warningCount } , { DiagnosticSeverity . Information } = { infoCount } ";
506
- if ( warningCount + errorCount == 0 )
507
- {
508
- ConsoleHostHelper . DisplayMessageUsingSystemProperties ( Host , "WarningForegroundColor" , "WarningBackgroundColor" , message ) ;
509
- }
510
- else
511
- {
512
- ConsoleHostHelper . DisplayMessageUsingSystemProperties ( Host , "ErrorForegroundColor" , "ErrorBackgroundColor" , message ) ;
513
- }
514
+ ConsoleHostHelper . DisplayMessageUsingSystemProperties ( Host , "ErrorForegroundColor" , "ErrorBackgroundColor" , message ) ;
514
515
}
515
516
}
516
517
}
0 commit comments