Style Checking for PowerShell Scripts. #829
Labels
Central-EngSys
This issue is owned by the Engineering System team.
EngSys
This issue is impacting the engineering system.
To help drive consistency for many of the tools/scripts written in PowerShell I think that we should reach some team wide consensus on Style Guidelines for PowerShell code that can be enforced as part of CI.
A good option for this will be to make use of
PSScriptAnalyzer
which is already bundled with the Microsoft PowerShell extension for VSCode but can also be run in PowerShell and therefore as part of CI.One way we can go about this is to first decide on the coding style to follow using either preset settings or manually configuring rules .
VSCode users will be able to adopt some of these setting as part of their workspace code formatting setting which will allow formatting on the fly/ on save. But we should add a script which runs
Invoke-ScriptAnalyzer
using the agreed on set of rules. This will allow for testing of new scripts locally as well as style enforcement on CI.Invoke-ScriptAnalyzer
also helps automatically fix some of the rules but it does not seem to be implemented perfectly right now so we'll still need to manually fix a few things before checking in script.Here is some community discussions about PowerShell coding styles PoshCode/PowerShellPracticeAndStyle#81
The text was updated successfully, but these errors were encountered: