Overview
PSScriptAnalyzer
(PSSA
) 1.18.1
is now available on the PSGallery and fixes not only a lot of the issues reported for 1.18.0
but has also been made twice as faster compared to 1.18.0
. Additionally, the -SaveDscDependency
switch on Invoke-ScriptAnalyzer
has been improved to be platform agnostic and should now also work on Linux systems if DSC has been set up. A long standing concurrency bug related to analysing module manifest has also been fixed. Analysis showed that Test-ModuleManifest
is not thread-safe due to a bug either in the cmdlet or in the PowerShell engine itself, we resolved it by having a lock around calls to this cmdlet.
Formatter Fixes
This applies especially to its usage within the VS Code PowerShell extension:
- The new
PSUseCorrectCasing
formatting rule had to be adjusted to not expand/change paths and to treat wildcard characters correctly. Under the hood the rule callsGet-Command
and becauseGet-Command ?
returns all commands that have a name of length 1, it returnedForEach-Object
first, which made PSSA incorrectly change the?
alias forWhere-Object
toForEach-Object
. The PowerShell VS Code extension has thepowershell.codeFormatting.useCorrectCasing
setting that wraps around this configuration and the setting is currently defaulting tofalse
due to those issues that were found. With PSSA1.18.1
, we’d encourage you to enable the setting again as we think that we have fixed all issues and pending feedback we plan to enable the setting by default. Although the VS Code extension ships a backup version of PSSA (currently1.18.0
), one can always install PSScriptAnalyzer locally and the extension will pick it up. You can install the newer PSScriptAnalyzer version and start using it without having to wait for the extension to release an update. - The new
PipelineIndentation
configuration setting of thePSUseConsistentIndentation
formatting rule had a bug when it was set toIncreaseIndentationForFirstPipeline
orIncreaseIndentationAfterEveryPipeline
and in certain cases, indentation of code following the pipeline could be incorrectly indented. Currently the VS Code settingpowershell.codeFormatting.pipelineIndentationStyle
for it is set toNoIndentation
to avoid this bug. We encourage you here as well to try out the options again so that we can get feedback before we set the default of the VS Code setting toIncreaseIndentationForFirstPipeline
(which is the default when callingInvoke-Formatter
without parameters). This desired default was voted for by the community here.
Conclusion and Future Outlook
Please try out this new patch, if you install it using Install-Module
then the VS Code extension will automatically use it after a restart of the integrated terminal session or just by re-opening VS Code. Getting feedback in this period is very important so that the PowerShell team can make a decision on when to include 1.18.1
by default in one of the next updates of the PowerShell extension. After feedback of this phased rollout, we will consider changing the default settings in the extension as mentioned above. It is hard to anticipate all the use cases, so we chose to make features configurable behind new flags and rollout the changes to a smaller user group first.
The Changelog has more details if you want to dig further.
On behalf of the Script Analyzer team,
Christoph Bergmeister, Project Maintainer from the community
Jim Truher, Senior Software Engineer, Microsoft
The post Release of PowerShell Script Analyzer 1.18.1 appeared first on PowerShell.