Skip to content

Commit ac11a2d

Browse files
author
Quoc Truong
committed
Change remaining warning to error
1 parent f258a87 commit ac11a2d

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

Engine/ScriptAnalyzer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,10 @@ internal bool ParseProfile(string profile, PathIntrinsics path, IOutputWriter wr
281281
excludeRuleList = excludeRuleList.Union(rhsList);
282282
break;
283283
default:
284-
// keep writing warning here, we only stop processing if existing keys are wrong
285-
writer.WriteWarning(
286-
string.Format(CultureInfo.CurrentCulture, Strings.WrongKey, key,
287-
kvp.Item1.Extent.StartLineNumber, kvp.Item1.Extent.StartColumnNumber, profile));
284+
writer.WriteError(new ErrorRecord(
285+
new InvalidDataException(string.Format(CultureInfo.CurrentCulture, Strings.WrongKey, key, kvp.Item1.Extent.StartLineNumber, kvp.Item1.Extent.StartColumnNumber, profile)),
286+
Strings.WrongConfigurationKey, ErrorCategory.InvalidData, profile));
287+
hasError = true;
288288
break;
289289
}
290290
}

Engine/Strings.Designer.cs

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Engine/Strings.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
<value>Cannot find any DiagnosticRecord with the Rule Suppression ID {0}.</value>
194194
</data>
195195
<data name="WrongKey" xml:space="preserve">
196-
<value>{0} is not a valid key in the profile hashtable: line {1} column {2} in file {3}. This key value pair will not be processed.</value>
196+
<value>{0} is not a valid key in the profile hashtable: line {1} column {2} in file {3}. Valid keys are ExcludeRules, IncludeRules and Severity.</value>
197197
</data>
198198
<data name="WrongKeyFormat" xml:space="preserve">
199199
<value>Key in the profile hashtable should be a string: line {0} column {1} in file {2}</value>
@@ -231,4 +231,7 @@
231231
<data name="ConfigurationValueWrongFormat" xml:space="preserve">
232232
<value>ConfigurationValueWrongFormat</value>
233233
</data>
234+
<data name="WrongConfigurationKey" xml:space="preserve">
235+
<value>WrongConfigurationKey</value>
236+
</data>
234237
</root>

Tests/Engine/GlobalSuppression.test.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Describe "GlobalSuppression" {
7777
It "Raises Error for wrong profile" {
7878
$invokeWithError = Invoke-ScriptAnalyzer "$directory\GlobalSuppression.ps1" -Configuration "$directory\WrongProfile.ps1" -ErrorAction SilentlyContinue
7979
$invokeWithError.Count | should be 0
80-
$Error[0].FullyQualifiedErrorId | should match "ConfigurationValueWrongFormat,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand"
80+
$Error[0].FullyQualifiedErrorId | should match "WrongConfigurationKey,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand"
8181
}
8282
}
8383
}

0 commit comments

Comments
 (0)