GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — 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 Conversation
|
| "IsCoreCLR", "IsLinux", "IsMacOS", "IsWindows" | ||
| }; | ||
|
|
||
| private static readonly IList<string> _automaticVariablesThatCouldBeProblematicToAssignTo = new List<string>() |
There was an error while loading. Please reload this page.
There was a problem 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>() |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
How about _writeableAutomaticVariables and _readonlyAutomaticVariables?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
👌
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-Authored-By: Robert Holt <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Update PSAvoidAssignmentToAutomaticVariable to detect more automatic variables New Rule Suggestion: AvoidReuseOfAutomaticVariables
There was an error while loading. Please reload this page.