Skip to content

Commit 56c6ea1

Browse files
authored
Invoke-ScriptAnalyzer: Stream diagnostics instead of batching (#2062)
Before this commit, diagnostics for all analyzed files in this pipeline step were batched and logged at once. With this commit, diagnostics are rendered immediately.
1 parent 01a3259 commit 56c6ea1

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

Engine/Commands/InvokeScriptAnalyzerCommand.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -434,29 +434,39 @@ private void ProcessInput()
434434
WriteToOutput(RunAnalysis());
435435
}
436436

437-
private List<DiagnosticRecord> RunAnalysis()
437+
private IEnumerable<DiagnosticRecord> RunAnalysis()
438438
{
439439
if (!IsFileParameterSet())
440440
{
441-
return ScriptAnalyzer.Instance.AnalyzeScriptDefinition(scriptDefinition, out _, out _);
441+
foreach (var record in ScriptAnalyzer.Instance.AnalyzeScriptDefinition(scriptDefinition, out _, out _))
442+
{
443+
yield return record;
444+
}
445+
yield break;
442446
}
443447

444-
var diagnostics = new List<DiagnosticRecord>();
445-
foreach (string path in this.processedPaths)
448+
foreach (var path in this.processedPaths)
446449
{
450+
if (!ShouldProcess(path, $"Analyzing path with Fix={this.fix} and Recurse={this.recurse}"))
451+
{
452+
continue;
453+
}
454+
447455
if (fix)
448456
{
449-
ShouldProcess(path, $"Analyzing and fixing path with Recurse={this.recurse}");
450-
diagnostics.AddRange(ScriptAnalyzer.Instance.AnalyzeAndFixPath(path, this.ShouldProcess, this.recurse));
457+
foreach (var record in ScriptAnalyzer.Instance.AnalyzeAndFixPath(path, this.ShouldProcess, this.recurse))
458+
{
459+
yield return record;
460+
}
451461
}
452462
else
453463
{
454-
ShouldProcess(path, $"Analyzing path with Recurse={this.recurse}");
455-
diagnostics.AddRange(ScriptAnalyzer.Instance.AnalyzePath(path, this.ShouldProcess, this.recurse));
464+
foreach (var record in ScriptAnalyzer.Instance.AnalyzePath(path, this.ShouldProcess, this.recurse))
465+
{
466+
yield return record;
467+
}
456468
}
457469
}
458-
459-
return diagnostics;
460470
}
461471

462472
private void WriteToOutput(IEnumerable<DiagnosticRecord> diagnosticRecords)

0 commit comments

Comments
 (0)