Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Engine/Commands/InvokeScriptAnalyzerCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,19 @@ public SwitchParameter AttachAndDebug
set { attachAndDebug = value; }
}
private bool attachAndDebug = false;

#endif
/// <summary>
/// If true, reports an additional single line summary of issue counts.
/// </summary>
[Parameter(Mandatory = false)]
public SwitchParameter ReportSummary
{
get { return reportSummary; }
set { reportSummary = value; }
}
private SwitchParameter reportSummary;

#endregion Parameters

#region Overrides
Expand Down Expand Up @@ -424,9 +436,32 @@ private void WriteToOutput(IEnumerable<DiagnosticRecord> diagnosticRecords)
{
foreach (ILogger logger in ScriptAnalyzer.Instance.Loggers)
{
var errorCount = 0;
var warningCount = 0;
var infoCount = 0;

foreach (DiagnosticRecord diagnostic in diagnosticRecords)
{
logger.LogObject(diagnostic, this);
switch (diagnostic.Severity)
{
case DiagnosticSeverity.Information:
infoCount++;
break;
case DiagnosticSeverity.Warning:
warningCount++;
break;
case DiagnosticSeverity.Error:
errorCount++;
break;
default:
throw new ArgumentOutOfRangeException(nameof(diagnostic.Severity), $"Severity '{diagnostic.Severity}' is unknown");
}
}

if (ReportSummary.IsPresent)
{
Host.UI.WriteLine($"{DiagnosticSeverity.Error} : {errorCount} \t {DiagnosticSeverity.Warning} : {warningCount} \t {DiagnosticSeverity.Information} : {infoCount}");
}
}

Expand Down