Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUpdate PSUseCorrectCasing to enforce correct casing of automatic variables #1401
Comments
|
Certainly possible. Would we take the union of automatic variables from Windows PowerShell and PowerShell Core? |
|
There should only be rule violations for automatic variables present in the test environment. We can access a list of special variables at runtime by reflection: [ref].
Assembly.
GetType('System.Management.Automation.SpecialVariables').
DeclaredFields.
Where{ $PSItem.FieldType -eq [string] }.
ForEach{ $PSItem.GetValue($null) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary of the new feature
Incorrect case of automatic variables should result in a PSUseCorrectCasing rule violation.
Proposed technical implementation details (optional)
Code using
$errorshould result in a rule violationReplacement with
$Errorshould be suggested as a fix.What is the latest version of PSScriptAnalyzer at the point of writing
1.18.3