Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style Checking for PowerShell Scripts. #829

Open
chidozieononiwu opened this issue Jul 30, 2020 · 2 comments
Open

Style Checking for PowerShell Scripts. #829

chidozieononiwu opened this issue Jul 30, 2020 · 2 comments
Assignees
Labels
Central-EngSys This issue is owned by the Engineering System team. EngSys This issue is impacting the engineering system.

Comments

@chidozieononiwu
Copy link
Member

chidozieononiwu commented Jul 30, 2020

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

@chidozieononiwu chidozieononiwu added the EngSys This issue is impacting the engineering system. label Jul 30, 2020
@weshaggard
Copy link
Member

As part of setting up a PS standard we should also consider setting strict mode https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/set-strictmode?view=powershell-7.

@benbp
Copy link
Member

benbp commented Jun 20, 2022

Related #3473

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Central-EngSys This issue is owned by the Engineering System team. EngSys This issue is impacting the engineering system.
Projects
Status: 🤔 Triage
Development

No branches or pull requests

4 participants