PSScriptAnalyzer 1.19.1 is now available on the PowerShell Gallery. This minor update fixes a few user-reported bugs and introduces a new rule (which is disabled by default) for avoiding using double quotes for constant strings. To install this version of the module, open any PowerShell console and run:
Install-Module PSScriptAnalyzer -Force -Repository PSGallery
AvoidUsingDoubleQuotesForConstantString (disabled by default)
Severity Level: Information
When the value of a string is constant (i.e. not being interpolated by injecting variables or expression into such as e.g.
"$PID-$(hostname)"), then single quotes should be used to express the constant nature of the string. This is not only to make the intent clearer that the string is a constant and makes it easier to use some special characters such as e.g.
$ within that string expression without the need to escape them. There are exceptions to that when double quoted strings are more readable though, e.g. when the string value itself has to contain a single quote (which would require a double single quotes to escape the character itself) or certain very special characters such as e.g.
"\n" are already being escaped, the rule would not warn in this case as it is up to the author to decide on what is more readable in those cases.
$constantValue = "I Love PowerShell"
$constantValue = 'I Love PowerShell'
- Fix bug that caused incorrect formatting in hashtables in the non-default setting PipelineIndentationStyle.None (if you do use this setting we ask that users to try it out again as the long term idea is to make it the default setting)
- Fix ArgumentException when the same variable name is used in 2 different sessions
- Fixed bugs with
- Fixes issue when
CommandInfoParametersproperty throws due to runspace affinity problem of PowerShell engine
- Fix token check with new lines
CheckParameterbug when using interpolated string
For the full list of changes please refer to the change log.
What’s next for PSScriptAnalyzer
We are currently working on a major rearchitecture of PSScriptAnalyzer, we are calling this project PSScriptAnalyzer 2.0, and hope to have previews available fall 2020.
To understand the goals of the project and track our progress please refer to this roadmap. Within our GitHub repository we are using the issue tag “Consider-2.0” to track bugs and features that we are hoping to resolve in the release. As we get closer to releasing versions of this rearchitecture we will shift to a “Resolved-2.0” tag to mark issues that are expected to be resolved by the time PSScriptAnalyzer 2.0 becomes generally available.
Now is a great time to give us feedback around the priorities for improvements and features/use cases of the module as we are still in the early stages of development. If you use PSScriptAnalyzer to build PowerShell tools, we would especially love your feedback on our API design.
Feedback and Support
The best place to get support on issues you may encounter or to give feedback/feature requests is through our GitHub Repository.
Sydney Smith PowerShell Team