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

Update PSAvoidAssignmentToAutomaticVariable to detect more automatic variables #1183

Closed
jegannathanmaniganadan opened this issue Mar 22, 2019 · 3 comments · Fixed by #1394
Closed

Comments

@jegannathanmaniganadan
Copy link
Contributor

I think this rule detects only limited number of automatic variables, we should probably update this with https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-6

I am not sure whats the reason behind having only limited number of variables (may be they are read-only ?). But the rule name conveys different meaning.

We should change the rule name or let it flag all the automatic variable or make it ConfigurableRule

@jegannathanmaniganadan jegannathanmaniganadan changed the title Update PSAvoidAssignmentToAutomaticVariable with all the automatic variable Update PSAvoidAssignmentToAutomaticVariable to detect all the automatic variables Mar 22, 2019
@bergmeister
Copy link
Collaborator

bergmeister commented Mar 22, 2019

The reason why it flags the readonly ones at the moment is because one can be sure that assignment to those does not make sense. There are built in variables that can be assigned to by fesign, therefore we cannot just flag against all of those. But there are certainly a few more variables that we could add to the list, the work just has not been done yet to determine which other variables we should also warn against. I'd be happy to discuss it if someone like you does the research and adds more variables to it. The $args variable is one of those that I personally would like to add.

@bergmeister bergmeister changed the title Update PSAvoidAssignmentToAutomaticVariable to detect all the automatic variables Update PSAvoidAssignmentToAutomaticVariable to detect more automatic variables Mar 22, 2019
@jegannathanmaniganadan
Copy link
Contributor Author

I logged this because it did not flag $Matches variable. Why can't we make it configurable.

@bergmeister
Copy link
Collaborator

Ideally, we should just add the variables that we sure of should not be modified to the blacklist so that everyone can benefit from it but having an optional configuration that allows to add more variables would be possible as well. Feel free to create a PR either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants