Skip to content

Exclude PSNativeCommandArgumentPassing variable #2093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Engine/SpecialVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ internal enum PreferenceVariable
internal const string PSEmailServer = "PSEmailServer";
internal const string PSDefaultParameterValues = "PSDefaultParameterValues";
internal const string PSModuleAutoLoadingPreference = "PSModuleAutoLoadingPreference";
internal const string PSNativeCommandArgumentPassing = "PSNativeCommandArgumentPassing";
internal const string pwd = "PWD";
internal const string Null = "null";
internal const string True = "true";
Expand All @@ -182,6 +183,7 @@ internal enum PreferenceVariable
PSEmailServer,
PSDefaultParameterValues,
PSModuleAutoLoadingPreference,
PSNativeCommandArgumentPassing,
pwd,
Null,
True,
Expand Down
6 changes: 6 additions & 0 deletions Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ function MyFunc2() {
Should -Be 0
}

It "does not flag `$PSNativeCommandArgumentPassing variable" {
Invoke-ScriptAnalyzer -ScriptDefinition '$PSNativeCommandArgumentPassing=None' -IncludeRule $violationName | `
Get-Count | `
Should -Be 0
}

It "does not flag global variable" {
Invoke-ScriptAnalyzer -ScriptDefinition '$global:x=$null' -IncludeRule $violationName | `
Get-Count | `
Expand Down