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-ScriptAnalyzerhas 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.
This applies especially to its usage within the VS Code PowerShell extension:
- The new
PSUseCorrectCasingformatting rule had to be adjusted to not expand/change paths and to treat wildcard characters correctly. Under the hood the rule calls
Get-Command ?returns all commands that have a name of length 1, it returned
ForEach-Objectfirst, which made PSSA incorrectly change the
ForEach-Object. The PowerShell VS Code extension has the
powershell.codeFormatting.useCorrectCasingsetting that wraps around this configuration and the setting is currently defaulting to
falsedue to those issues that were found. With PSSA
1.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 (currently
1.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
PipelineIndentationconfiguration setting of the
PSUseConsistentIndentationformatting rule had a bug when it was set to
IncreaseIndentationAfterEveryPipelineand in certain cases, indentation of code following the pipeline could be incorrectly indented. Currently the VS Code setting
powershell.codeFormatting.pipelineIndentationStylefor it is set to
NoIndentationto 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 to
IncreaseIndentationForFirstPipeline(which is the default when calling
Invoke-Formatterwithout 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