Skip to content

Commit 6e9e30c

Browse files
committed
Clean up processing logic in Invoke-ScriptAnalyzer
1 parent 50bdfa9 commit 6e9e30c

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

Engine/Commands/InvokeScriptAnalyzerCommand.cs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -427,29 +427,32 @@ protected override void StopProcessing()
427427

428428
private void ProcessInput()
429429
{
430-
IEnumerable<DiagnosticRecord> diagnosticsList = Enumerable.Empty<DiagnosticRecord>();
431-
if (IsFileParameterSet())
430+
WriteToOutput(RunAnalysis());
431+
}
432+
433+
private IEnumerable<DiagnosticRecord> RunAnalysis()
434+
{
435+
if (!IsFileParameterSet())
432436
{
433-
foreach (var p in processedPaths)
434-
{
435-
if (fix)
436-
{
437-
ShouldProcess(p, $"Analyzing and fixing path with Recurse={this.recurse}");
438-
diagnosticsList = ScriptAnalyzer.Instance.AnalyzeAndFixPath(p, this.ShouldProcess, this.recurse);
439-
}
440-
else
441-
{
442-
ShouldProcess(p, $"Analyzing path with Recurse={this.recurse}");
443-
diagnosticsList = ScriptAnalyzer.Instance.AnalyzePath(p, this.ShouldProcess, this.recurse);
444-
}
445-
WriteToOutput(diagnosticsList);
446-
}
437+
return ScriptAnalyzer.Instance.AnalyzeScriptDefinition(scriptDefinition, out _, out _);
447438
}
448-
else
439+
440+
var diagnostics = new List<DiagnosticRecord>();
441+
foreach (string path in this.processedPaths)
449442
{
450-
diagnosticsList = ScriptAnalyzer.Instance.AnalyzeScriptDefinition(scriptDefinition, out _, out _);
451-
WriteToOutput(diagnosticsList);
443+
if (fix)
444+
{
445+
ShouldProcess(path, $"Analyzing and fixing path with Recurse={this.recurse}");
446+
diagnostics.AddRange(ScriptAnalyzer.Instance.AnalyzeAndFixPath(path, this.ShouldProcess, this.recurse));
447+
}
448+
else
449+
{
450+
ShouldProcess(path, $"Analyzing path with Recurse={this.recurse}");
451+
diagnostics.AddRange(ScriptAnalyzer.Instance.AnalyzePath(path, this.ShouldProcess, this.recurse));
452+
}
452453
}
454+
455+
return diagnostics;
453456
}
454457

455458
private void WriteToOutput(IEnumerable<DiagnosticRecord> diagnosticRecords)

0 commit comments

Comments
 (0)