- Notifications
You must be signed in to change notification settings - Fork407
Enhance UseDeclaredVarsMoreThanAssignments to detect also take into account the usage of Get-Variable with an array of variables and usage of named parameter -Name#1310
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
rjmholt left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
This makes me think we should really invest in some general purpose AST functionality (like parameter parsing/binding tools) (but probably don't have the time currently).
Otherwise, LGTM
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
…simplify local method
bergmeister commentedAug 19, 2019
Yes, I agree something like a parameter binder helper would be nice but I think it would require the runtime and be no purely static just based on the AST. Maybe some of the parameter binder functionality in PowerShell could be exposed? |
PR Summary
Fixes#1301 by enhancing the parsing of the
Get-VariableAST to also check if an array is passed or if the-Nameparameter is used as a named parameter (including cases where it is shortened to-n).Also refactored logic into it's own static method for better readability and performance.
Since reverse engineering a
CommandAstinto the used parameters is quite complex, I am not going to further enhance it.PR Checklist
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.