Add more automatic variables to PSAvoidAssignmentToAutomaticVariables that are not read-only but should still not be assigned to in most cases by bergmeister · Pull Request #1394 · PowerShell/PSScriptAnalyzer
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel we should avoid embedding clausal descriptions in variable names if we can -- and also I can't think of an automatic variable that's not problematic to assign to (since, being automatic, they could be reassigned unexpectedly)
| private static readonly IList<string> _automaticVariablesThatCouldBeProblematicToAssignTo = new List<string>() | |
| private static readonly IList<string> _automaticVariables = new List<string>() |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to differentiate from the _readOnlyAutomaticVariables variable above where PowerShell actually itself throws an error when trying to assign, those variables don't.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well one is readonly variables and the other is just automatic variables, no? So _readonlyVariables and _automaticVariables or _writeableAutomaticVariables maybe?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just prefer not to call the variable something that embeds a sentence
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about _writeableAutomaticVariables and _readonlyAutomaticVariables?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌