Skip to content

Commit 675cc85

Browse files
author
Kapil Borle
committed
Update TryAddingProfileItem member
* Changes the name to AddProfileItem * Adds input argument validation
1 parent f1665be commit 675cc85

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Engine/ScriptAnalyzer.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
using System.Threading.Tasks;
2929
using System.Collections.ObjectModel;
3030
using System.Collections;
31+
using System.Diagnostics;
3132

3233
namespace Microsoft.Windows.PowerShell.ScriptAnalyzer
3334
{
@@ -216,13 +217,19 @@ internal bool ParseProfile(object profileObject, PathIntrinsics path, IOutputWri
216217
return true;
217218
}
218219

219-
private bool TryAddingProfileItem(
220+
private bool AddProfileItem(
220221
string key,
221222
List<string> values,
222223
List<string> severityList,
223224
List<string> includeRuleList,
224225
List<string> excludeRuleList)
225226
{
227+
Debug.Assert(key != null);
228+
Debug.Assert(values != null);
229+
Debug.Assert(severityList != null);
230+
Debug.Assert(includeRuleList != null);
231+
Debug.Assert(excludeRuleList != null);
232+
226233
switch (key.ToLower())
227234
{
228235
case "severity":
@@ -317,7 +324,7 @@ private bool ParseProfileHashtable(Hashtable profile, PathIntrinsics path, IOutp
317324
}
318325
}
319326

320-
TryAddingProfileItem(key, values, severityList, includeRuleList, excludeRuleList);
327+
AddProfileItem(key, values, severityList, includeRuleList, excludeRuleList);
321328

322329
}
323330

@@ -437,7 +444,7 @@ private bool ParseProfileString(string profile, PathIntrinsics path, IOutputWrit
437444

438445
string key = (kvp.Item1 as StringConstantExpressionAst).Value.ToLower();
439446

440-
if(!TryAddingProfileItem(key, rhsList, severityList, includeRuleList, excludeRuleList))
447+
if(!AddProfileItem(key, rhsList, severityList, includeRuleList, excludeRuleList))
441448
{
442449
writer.WriteError(new ErrorRecord(
443450
new InvalidDataException(string.Format(CultureInfo.CurrentCulture, Strings.WrongKey, key, kvp.Item1.Extent.StartLineNumber, kvp.Item1.Extent.StartColumnNumber, profile)),

0 commit comments

Comments
 (0)