Skip to content

Commit 09588c2

Browse files
author
Kapil Borle
committed
Fix failing tests
1 parent 60fe6c9 commit 09588c2

File tree

2 files changed

+23
-60
lines changed

2 files changed

+23
-60
lines changed

Engine/Commands/InvokeScriptAnalyzerCommand.cs

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public object Settings
190190
private bool stopProcessing;
191191

192192
/// <summary>
193-
/// Resolve DSC resoure dependency
193+
/// Resolve DSC resource dependency
194194
/// </summary>
195195
[Parameter(Mandatory = false)]
196196
public SwitchParameter ResolveDscResourceDependency
@@ -257,6 +257,21 @@ protected override void ProcessRecord()
257257
}
258258
}
259259

260+
protected override void EndProcessing()
261+
{
262+
ScriptAnalyzer.Instance.CleanUp();
263+
base.EndProcessing();
264+
}
265+
266+
protected override void StopProcessing()
267+
{
268+
ScriptAnalyzer.Instance.CleanUp();
269+
base.StopProcessing();
270+
}
271+
272+
#endregion
273+
274+
#region Methods
260275
private void ProcessInput()
261276
{
262277
IEnumerable<DiagnosticRecord> diagnosticsList = Enumerable.Empty<DiagnosticRecord>();
@@ -269,61 +284,26 @@ private void ProcessInput()
269284
diagnosticsList = ScriptAnalyzer.Instance.AnalyzePath(
270285
this.SessionState.Path.GetUnresolvedProviderPathFromPSPath(p.Path),
271286
this.recurse);
287+
WriteToOutput(diagnosticsList);
272288
}
273289
}
274290
else if (String.Equals(this.ParameterSetName, "ScriptDefinition", StringComparison.OrdinalIgnoreCase))
275291
{
276292
diagnosticsList = ScriptAnalyzer.Instance.AnalyzeScriptDefinition(scriptDefinition);
293+
WriteToOutput(diagnosticsList);
277294
}
295+
}
278296

297+
private void WriteToOutput(IEnumerable<DiagnosticRecord> diagnosticRecords)
298+
{
279299
foreach (ILogger logger in ScriptAnalyzer.Instance.Loggers)
280300
{
281-
foreach (DiagnosticRecord diagnostic in diagnosticsList)
301+
foreach (DiagnosticRecord diagnostic in diagnosticRecords)
282302
{
283303
logger.LogObject(diagnostic, this);
284304
}
285305
}
286306
}
287-
288-
protected override void EndProcessing()
289-
{
290-
ScriptAnalyzer.Instance.CleanUp();
291-
base.EndProcessing();
292-
}
293-
294-
protected override void StopProcessing()
295-
{
296-
ScriptAnalyzer.Instance.CleanUp();
297-
base.StopProcessing();
298-
}
299-
300-
#endregion
301-
302-
#region Methods
303-
304-
//private void ProcessPathOrScriptDefinition(string pathOrScriptDefinition)
305-
//{
306-
// IEnumerable<DiagnosticRecord> diagnosticsList = Enumerable.Empty<DiagnosticRecord>();
307-
308-
// if (String.Equals(this.ParameterSetName, "File", StringComparison.OrdinalIgnoreCase))
309-
// {
310-
// diagnosticsList = ScriptAnalyzer.Instance.AnalyzePath(pathOrScriptDefinition, this.recurse);
311-
// }
312-
// else if (String.Equals(this.ParameterSetName, "ScriptDefinition", StringComparison.OrdinalIgnoreCase))
313-
// {
314-
// diagnosticsList = ScriptAnalyzer.Instance.AnalyzeScriptDefinition(pathOrScriptDefinition);
315-
// }
316-
317-
// //Output through loggers
318-
// foreach (ILogger logger in ScriptAnalyzer.Instance.Loggers)
319-
// {
320-
// foreach (DiagnosticRecord diagnostic in diagnosticsList)
321-
// {
322-
// logger.LogObject(diagnostic, this);
323-
// }
324-
// }
325-
//}
326-
327307
#endregion
328308
}
329309
}

Engine/ScriptAnalyzer.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ public IEnumerable<DiagnosticRecord> AnalyzePath(string path, bool searchRecursi
11701170
this));
11711171
}
11721172

1173-
// Precreate the list of script file paths to analyze. This
1173+
// Create in advance the list of script file paths to analyze. This
11741174
// is an optimization over doing the whole operation at once
11751175
// and calling .Concat on IEnumerables to join results.
11761176
this.BuildScriptPathList(path, searchRecursively, scriptFilePaths);
@@ -1185,23 +1185,6 @@ public IEnumerable<DiagnosticRecord> AnalyzePath(string path, bool searchRecursi
11851185
}
11861186
}
11871187

1188-
//private List<DiagnosticRecord> AnalyzePaths(
1189-
// IEnumerable<string> scriptFilePaths,
1190-
// ModuleDependencyHandler moduleHandler)
1191-
//{
1192-
// var diagnosticRecords = new List<DiagnosticRecord>();
1193-
// foreach (string scriptFilePath in scriptFilePaths)
1194-
// {
1195-
// // Yield each record in the result so that the
1196-
// // caller can pull them one at a time
1197-
// foreach (var diagnosticRecord in this.AnalyzeFile(scriptFilePath, moduleHandler))
1198-
// {
1199-
// diagnosticRecords.Add(diagnosticRecord);
1200-
// }
1201-
// }
1202-
// return diagnosticRecords;
1203-
//}
1204-
12051188
/// <summary>
12061189
/// Analyzes a script definition in the form of a string input
12071190
/// </summary>

0 commit comments

Comments
 (0)