From c7f770e4a332cc4cc79f9bccb04288d7390e89a6 Mon Sep 17 00:00:00 2001 From: Matej Kafka Date: Mon, 10 Feb 2025 23:39:05 +0100 Subject: [PATCH] Invoke-ScriptAnalyzer: Stream diagnostics instead of batching 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. --- .../Commands/InvokeScriptAnalyzerCommand.cs | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Engine/Commands/InvokeScriptAnalyzerCommand.cs b/Engine/Commands/InvokeScriptAnalyzerCommand.cs index 38a2ad9fe..18a632874 100644 --- a/Engine/Commands/InvokeScriptAnalyzerCommand.cs +++ b/Engine/Commands/InvokeScriptAnalyzerCommand.cs @@ -434,29 +434,39 @@ private void ProcessInput() WriteToOutput(RunAnalysis()); } - private List RunAnalysis() + private IEnumerable RunAnalysis() { if (!IsFileParameterSet()) { - return ScriptAnalyzer.Instance.AnalyzeScriptDefinition(scriptDefinition, out _, out _); + foreach (var record in ScriptAnalyzer.Instance.AnalyzeScriptDefinition(scriptDefinition, out _, out _)) + { + yield return record; + } + yield break; } - var diagnostics = new List(); - foreach (string path in this.processedPaths) + foreach (var path in this.processedPaths) { + if (!ShouldProcess(path, $"Analyzing path with Fix={this.fix} and Recurse={this.recurse}")) + { + continue; + } + if (fix) { - ShouldProcess(path, $"Analyzing and fixing path with Recurse={this.recurse}"); - diagnostics.AddRange(ScriptAnalyzer.Instance.AnalyzeAndFixPath(path, this.ShouldProcess, this.recurse)); + foreach (var record in ScriptAnalyzer.Instance.AnalyzeAndFixPath(path, this.ShouldProcess, this.recurse)) + { + yield return record; + } } else { - ShouldProcess(path, $"Analyzing path with Recurse={this.recurse}"); - diagnostics.AddRange(ScriptAnalyzer.Instance.AnalyzePath(path, this.ShouldProcess, this.recurse)); + foreach (var record in ScriptAnalyzer.Instance.AnalyzePath(path, this.ShouldProcess, this.recurse)) + { + yield return record; + } } } - - return diagnostics; } private void WriteToOutput(IEnumerable diagnosticRecords)