Style Checking for PowerShell Scripts.
- Dominant language
- C#
- Stars
- 135
- Forks
- 260
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 115
Description
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`](https://github.com/PowerShell/PSScriptAnalyzer#introduction) 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 ](https://github.com/PowerShell/PSScriptAnalyzer/tree/master/Engine/Settings) or manually configuring [rules ](https://github.com/PowerShell/PSScriptAnalyzer/tree/master/RuleDocumentation).
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 https://github.com/PoshCode/PowerShellPracticeAndStyle/issues/81
Contributor guide
Assessment
This issue has not been assessed yet.