-
Notifications
You must be signed in to change notification settings - Fork 233
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
Add PSAvoidAssignmentToAutomaticVariable to the default set of PSSA rules #1101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a low-risk change and a useful rule. LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is a good rule to have enabled by default. Thanks. |
Kudos to @mklement0 for proposing it originally. I had the intent of doing it when I did the rule but forgot it in the long process of the PSSA release and the extension using a new release... |
Thanks, @bergmeister; also worth mentioning that enhancements to this rule are coming, so as to also cover automatic variables that are technically writeable but shouldn't be; in case someone wants to help review the proposed change: see PowerShell/PSScriptAnalyzer#712 (comment) |
@bergmeister the bar is super high with backporting since the Preview will be stable in Jan. However, can you backport it? |
… to the default set of PSSA rules
See docs below for info. The rule warns only on read-only, automatic variables where assignment would cause an error to be thrown at runtime, therefore there is no scope for false positives.
https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/AvoidAssignmentToAutomaticVariable.md
Example of what would happen at runtime in the console if one ignored such a violation:
We should back-port this change