github PowerShell/PSScriptAnalyzer 1.19.0
PSScriptAnalyzer v1.19.0

latest releases: 1.22.0, 1.21.0, 1.20.0...
4 years ago

New Rules

Rule Enhancements

  • Add more automatic variables to PSAvoidAssignmentToAutomaticVariables that are not read-only but should still not be assigned to in most cases (#1394) (by @bergmeister)

Compatibility Rules

Formatter

  • UseCorrectCasing
  • UseConsistentIndentation
    • When non-default options are used, cater for the case of a comment between pipe and newline (#1463)
    • Add PipelineIndentationStyle.None option for scenarios where indentation is custom, inconsistent or the user does not like any of the 3 pipeline indentation styles (#1399) (by @bergmeister)
    • Fix complex case when PipelineIndentation is not set to default (NoIndentation) (#1359) (by @bergmeister)
  • UseConsistentWhitespace
    • Split CheckPipe feature of trimming redundant whitespace out into option CheckPipeForRedundantWhiteSpace (#1413) (by @bergmeister)
    • Set default of CheckParameter configuration setting to false to ensure that setting won't be enabled by default if an old version of the VS-Code extension uses a new version of - PSScriptAnalyzer (1.19) (#1411) (by @bergmeister)
    • Remove redundant whitespace between parameters with new option (disabled by default) in UseConsistentWhitespace (#1392) (by @bergmeister)
    • Ignore empty hashtable for CheckInnerBrace configuration (#1349) (by @bergmeister)

Performance

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

  • Eliminate initialization overhead, which can lead to a reduced time of up to 50%
  • Optimize operations in rules to make them scale better, another improvement of around 50%
  • The formatter used to re-parse the script in between every rule run but this is skipped now if the previous rule did not emit a 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:

  • Eliminate Regex overhead in AvoidTrailingWhitespace -> Speedup of 5% (PowerShell 5.1) or 2.5 % (PowerShell 7.1-preview.2) (#1465) (by @bergmeister)
  • Formatter: Recycle parsed AST and tokens in between rule invocations when no correction was applied to improve performance (#1462) (by @bergmeister)
  • Improve performance of UseConsistentIndentation even more > another 10% speedup for formatter (#1461) (by @bergmeister)
  • Improve performance of UseConsistentIndentation -> 35% speedup for formatter (#1458) (by @bergmeister)
  • Lazy initialisation of LinkedList in TokenOperations constructor -> 7% performance gain for formatter (#1453) (by @bergmeister)
  • Invoke-Formatter: Skip VariableAnalysis, which is not needed to yield a 50% performance improvement (#1451) (by @bergmeister)

Fixes

  • Fix edge case of PSUseConsistentIndentation for non-default value (IncreaseIndentationForFirstPipeline/IncreaseIndentationAfterEveryPipeline) (#1423) (by @bergmeister)
  • Fix rule suppression ID in compat rules (#1432) (by @rjmholt)
  • Changes to build analyzer for PS7 and PS6 and ship in separate directories and bump version to 1.19.0 (#1425) (by @JamesWTruher)
  • Use AST to determine SupportsShouldProcess when an error is thrown (#1397) (by @rjmholt)
  • Fix false positive of AvoidAlias rule for implicit aliasing of Get- commands for the CommandType ExternalScript (#1386) (by @bergmeister)

Build/Tests/Maintenance

  • Changelog for 1.19.0 (#1448) (by @bergmeister)
  • Use separate test.yaml files files since param passing of pwsh still doesn't seem to fully work correctly #1466 (by @bergmeister)
  • New build scripts for release pipeline (#1442) (by @JamesWTruher)
  • Make sure that tests always get uploaded, due to too much YAML indentation, condition was not applied (#1455) (by @bergmeister)
  • Cleanup csproj files: Remove code duplication for Configuration and entries in Rules project, since it depends on Engine project (#1450) (by @bergmeister)
  • Build: Use logging command as a temporary workaround due to billing bug preventing upload of pipeline artefacts (#1464) (by @bergmeister)
  • Use bracket syntax for passing yaml parameter (#1449) (by @bergmeister)
  • Update Newtonsoft.Json from 12.0.2 to 12.0.3 in Compatibility project as well (#1447) (by @bergmeister)
  • Replace usage of $MyInvocation.MyCommand.Path with $PSScriptRoot and cleanup tests as a preparation for Pester v5 (#1438) (by @bergmeister)
  • Compatibility tests: Use correct genericVerCases test case and remove invalid test case (#1440) (by @bergmeister)
  • Add out folder to .gitignore (#1443) (by @bergmeister)
  • Pin major version of Pester to 4 and upgrade Pester version for WMF4 build (#1433) (by @bergmeister)
  • ms-vscode.csharp to ms-dotnettools.csharp (#1424) (thanks @devlead!)
  • Upgrade .net sdk to latest path (#1421) (by @bergmeister)
  • Fix #1417 modulehelp false positives (#1418) (thanks @Jawz84!)
  • Increase macOs CI coverage to include both 10.14 and 10.15 as 10.15 has recently been added to Azure DevOps hosted agents (#1412) (by @bergmeister)
  • Fix vmImage entries in build to match description (#1409) (by @bergmeister)
  • Update .Net Core SDK from 3.1.100 to latest patch 3.1.101 (#1405) (by @bergmeister)
  • Multi-stage pipelines (to split build->test) (#1404) (by @bergmeister)
  • Use vmImage in yaml and merge build definitions into 1 by using jobs. Disable all AppVeyor images except for WMF4. Disable flaky UseCompatibleCommand tests on Ubuntu in CI (#1403) (by @bergmeister)
  • Azure pipelines migration (#1267) (by @bergmeister)
  • Add DevContainer support (#1286) (by @bergmeister)
  • Increase maximum runspace pool size in flaky test (#1358) (by @bergmeister)
  • Use latest version of PlatyPS in AppVeyor (#1390) (by @bergmeister)
  • .Net core sdk 3.1 (#1388) (by @bergmeister)
  • Use Where-Object instead of alias in buildmodule.tests.ps1 (#1360) (thanks @kvprasoon!)
  • Remove legacy methods (#1387) (by @bergmeister)
  • Upgrade .Net Core SDK version to a newer version that is also available in Visual Studio Online environment (#1377) (by @bergmeister)
  • Update Newtonsoft.Json from 12.0.1 to 12.02 (latest version), which increases the minimum PS Core version from 6.2.0 to 6.2.1 (#1357) (by @bergmeister)
  • Harden dotnet --version handling (#1367) (by @JamesWTruher)
  • Fix configuration for PS v5 and v6 builds to be Debug/Release as it used to be to allow for actual debug builds (#1356) (by @bergmeister)
  • Disable bad tests on Linux for now (#1365) (by @rjmholt)
  • Fix Ubuntu build and runspace test (#1340) (by @bergmeister)

Documentation

Don't miss a new PSScriptAnalyzer release

NewReleases is sending notifications on new releases.