Download ScriptAnalyzer from PowerShellGallery
Minimum required version when using PowerShell 7 is now 7.2.11
.
AvoidUsingDoubleQuotesForConstantString
information in overview README by @michaeltlombardi in https://github.com/PowerShell/PSScriptAnalyzer/pull/1883
Full Changelog: https://github.com/PowerShell/PSScriptAnalyzer/compare/1.21.0...1.22.0
.github/fabricbot.json
(#1812)process
aliasing Get-Process
with warning about misused syntax (#1638) (by @bergmeister)FunctionInfo
fallback AST attribute analysis for UseShouldProcessCorrectly (#1659) (thanks @hubuk)UseCorrectCasing
: Do not use CommandInfoCache when CommandInfoParameters property throws due to runspace affinity problem of PowerShell engine (#1523) (by @bergmeister)ReviewUnusedParameter
: Do not trigger when MyInvocation.BoundParameters or PSCmdlet.MyInvocation.BoundParameters is used (#1520) (Thanks @jegannathanmaniganadan!)PipelineIndentationStyle.None
: Fix bug that caused incorrect formatting in hashtables (#1497) (by @bergmeister)UseUsingScopeModifierInNewRunspaces
: Fix ArgumentException when the same variable name is used in 2 different sessions. (#1493) (by @bergmeister)UseConsistentWhitespace
The Formatter can now be multiple times faster depending on the use case and especially scaling problems were addressed that showed when analyzing large scripts with thousands of lines (a 3000 line test script was used in the below performance figures). Optimisations were to
DiagnosticRecord
as it means the script text hasn't changed and doesn't need updating. Therefore formatting will be faster on scripts that need no to little changes.A small improvement was made to a script analysis rule as well but the gain is offset by the addition of the new rules in this release.
The PRs for those improvements are:
This release adds one more important fix, which prevents a leak of runspaces when repeatedly invoking the PSScriptAnalyzer cmdlets. Furthermore it ups the minimum version of PowerShell Core to 6.2.0
due to 6.1
reaching its end of life this month.
This release mainly brings fixes and enhancements that are especially useful when being consumed by PowerShellEditorServices. The benefit to the user will be some enhancements and fixes in the formatter, especially around multiline commands. In addition to that, error messages emitted when using invalid syntax in the setting file are now much more meaningful and actionable.
Compatibility Analysis
Formatter
Engine
Please see the CHANGELOG for information about the changes in the release. You can download this version from PowerShellGallery.
Formatter
Compatibility Rules
DSC
-SaveDscDependency
work on Linux (#1246) (by @bergmeister)Enable suppression of custom rules when used together with -IncludeDefaultRules
to allow all possible scenarios from 1.17.1 and 1.18.0. This removes also the check if the rule name in the suppression attribute can be found because this check is technically not possible in all scenarios (#1245) (by @bergmeister)
Fix NullReferenceException for class type (#1182) (by @bergmeister)
2 improvements were made that make cold runs of ScriptAnalyzer twice as fast compared to 1.18.0
Get-Command
, making the rule twice (#1251) (by @JamesWTruher)Please see the CHANGELOG for information about the changes in the release. You can download this version from PowerShellGallery.
PowerShell Core
was raised from 6.0.2
to 6.1.0
due to 6.0
having reached the end of its support life-cycle. (#1165)Newtonsoft.Json
to 11.0.2
. (#1165) (by @bergmeister)6.0
were removed. Updated files for PowerShell 6.1
were added. This means that users that have customized the UseCompatibleCmdlets
rule, need to either adapt the version string as per rule documentation or can alternatively copy in the old command data files into the Settings
installation folder (#1075) (by @bergmeister)4.5.1
to 4.5.2
as 4.5.1
is not supported any more. If the OS is patched then Windows update will have ensured that the newer runtime patch is available. (#1108) (by @bergmeister)UseCorrectCasing
formatting rule for cmdlet/function name (#1117) (by @bergmeister)PSUseConsistentIndentationRule
to handle pipes correctly when there is a multi-line statement after a pipe and add PipelineIndentation
customisation option for it (#1102) (by @bergmeister)CheckInnerBrace
and CheckPipe
options to PSUseConsistentWhitespace
(#1092) (by @bergmeister)2.0
(#1091) (by @bergmeister)6.1.0
(#1075) (by @bergmeister)UseCompatibleCommands
, UseCompatibleSyntax
and UseCompatibleTypes
(#1156, #1133, #1176 and #1179) (by @rjmholt and @JamesWTruher)PossibleIncorrectComparisonWithNull
rule return a SuggestCorrection
for auto-fixes in VS-Code or via the -Fix switch (#1115) (by @bergmeister)RuleSuppressionID
for custom rules as well (#1144) (by @bergmeister)Import-DscRessource
for -SaveDscDependency
switch (#1138) (by @bergmeister)-SaveDscDependency
switch (#1094) (by @bergmeister)Multi-threading efficiency was highly improved leading to a speedup whilst keeping the CPU usage roughly the same. One can expect PSScriptAnalyzer
(PSSA) 1.18.0 to be more than twice as fast in most situations (including 'cold' runs) compared to its predecessor 1.17.0.
6.1.0
due to 6.0 running out of support now and update Newtonsoft.Json to 11.0.2
(#1165) (by @bergmeister)Microsoft.Management.Infrastructure
and update System.Reflection.TypeExtensions
NuGet package (#1105) (by @bergmeister)2.2.104
(latest patch) (#1158) (by @bergmeister)Microsoft.Management.Infrastructure
(#1059) (by @bergmeister)Microsoft.PowerShell.5.ReferenceAssemblies
from 1.0.0 to 1.1.0
and remove redundant/transitive references (#1050) (by @bergmeister)System.Reflection.TypeExtensions
and Microsoft.CSharp
) and make them more consistent (#1051) (by @bergmeister)TLS 1.2
for bootstrapping dotnet in CI (#1047) (by @bergmeister)CommunityAnalyzerRules
(#1119) (Thanks @kvprasoon!)PSUseConsistentWhiteSpace
: enhance example and correct argument type. #1069 (Thanks @TheIncorrigible1!)Please see the CHANGELOG for information about the changes in the release. You can download this version from PowerShellGallery.
Note: The minimum supported/working version of PowerShell Core is 6.0.2.
Patches 1.17.0 mainly to fix
-SkipPublisherCheck
switch on Install-Module
(#1014)PSAvoidAssignmentToAutomaticVariable
(#1007, #1013, #1014) (by @bergmeister, thanks @lipkau and @SeeminglyScience for reporting the issues)