Skip to content

Commit

Permalink
add ErrorView to SpecialVars and create test
Browse files Browse the repository at this point in the history
  • Loading branch information
ewisniew0 committed Nov 22, 2022
1 parent 9a6ce97 commit b9f1149
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Engine/SpecialVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ static SpecialVars()
internal const string ConfirmPreference = "ConfirmPreference";
internal const string ProgressPreference = "ProgressPreference";
internal const string InformationPreference = "InformationPreference";
internal const string ErrorView = "ErrorView";

internal static readonly string[] PreferenceVariables = new string[]
{
Expand All @@ -101,7 +102,8 @@ static SpecialVars()
WarningPreference,
ConfirmPreference,
ProgressPreference,
InformationPreference
InformationPreference,
ErrorView
};

internal static readonly Type[] PreferenceVariableTypes = new Type[]
Expand All @@ -114,6 +116,7 @@ static SpecialVars()
/* ConfirmPreference */ typeof(ConfirmImpact),
/* ProgressPreference */ typeof(Enum),
/* InformationPreference */ typeof(ActionPreference),
/* ErrorView */ typeof(ErrorView),
};

internal enum AutomaticVariable
Expand Down
5 changes: 5 additions & 0 deletions Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ function MyFunc2() {
}

Context "When there are no violations" {
It "No warning is issued for assignment without use of preference variable ErrorView" {
$results = Invoke-ScriptAnalyzer -ScriptDefinition '$ErrorView = NormalView'
$results.Count | Should -Be 0
}

It "returns no violations" {
$noViolations.Count | Should -Be 0
}
Expand Down

0 comments on commit b9f1149

Please sign in to comment.