Skip to content
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

Assignment of invalid values to local action preference variables #239

Open
nightroman opened this issue Jun 10, 2015 · 1 comment
Open

Comments

@nightroman
Copy link

Not global action preference variables are not strongly typed. As a result,
anything can be assigned to them, not necessarily valid values. For example,
typos will not be reported as errors, unlike with global variables.

In other words, PSSA should report issues like this, mind the typo:

$VerbosePreference = 'Cotninue'

References:

@nightroman
Copy link
Author

And it's not just about typos. Ingore is valid in v3+ but invalid in v2, Suspend is valid in v4+ and invalid in v3-.

Properly designed code takes care of such things, e.g. in Pester:

if ($PSVersionTable.PSVersion.Major -ge 3)
{
    $script:IgnoreErrorPreference = 'Ignore'
}
else
{
    $script:IgnoreErrorPreference = 'SilentlyContinue'
}

@raghushantha raghushantha self-assigned this Dec 1, 2015
@raghushantha raghushantha removed their assignment Feb 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants