-
Notifications
You must be signed in to change notification settings - Fork 11
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
(#32) Add PSScriptAnalyzer #73
Conversation
fb2fa47
to
ecb082d
Compare
12b9446
to
b4f2491
Compare
b4f2491
to
349e794
Compare
6d5e01a
to
b07b890
Compare
b07b890
to
7d499c2
Compare
NOTE: As a result of running the build using the changes in this PR, two new PowerShell Modules will be installed, PSScriptAnalyzer, and ConvertToSARIF. |
@TheCakeIsNaOH would be great to get your thoughts on this PR as well. I have made some changes on top of the work that you originally did here. Mainly around the installation of the PS Modules, and also switching to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the concept looks good, a couple of comments/questions.
7d499c2
to
4662ea8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing any additional concerns here beyond what @TheCakeIsNaOH has already raised tbh, this looks pretty good otherwise. :3
This adds a task to run PSScriptAnalyzer. It utilizes the Cake.Powershell module to run a script that will get ps1/psm1 files that are not excluded and run them through the specified settings file. Either a default formatting only run can be done, or custom run(s) can be specified. A custom base analysis path, setting file and set of folder exclusions can be specified for each run. For example, a custom run can be created to check that the Chocolatey powershell helpers use only the PSv2 cmdlets. The default run is for formatting, it checks files against the build in formatting related rules. This run can be expanded in the future, once enough projects are up to a baseline of good scripting practices.
4662ea8
to
5f1a4d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@TheCakeIsNaOH thanks again for the start on this work! Really appreciate it! |
Description Of Changes
This adds a task to run PSScriptAnalyzer. It utilizes the Cake.Powershell
module to run a script that will get ps1/psm1 files that are not excluded
and run them through the specified settings file.
Either a default formatting only run can be done, or custom run(s) can be
specified. A custom base analysis path, setting file and set of folder
exclusions can be specified for each run. For example, a custom run can
be created to check that the Chocolatey powershell helpers use only the
PSv2 cmdlets.
The default run is for formatting, it checks files against the build in
formatting related rules. This run can be expanded in the future, once
enough projects are up to a baseline of good scripting practices.
Motivation and Context
See #32
Testing
build.bat
. The build should complete successfully, and a new taskRun-PSScriptAnalyzer
should be completed, which adds two new files into thecode_drop\TestResults\PSScriptAnalyzer
folderbuild.bat --shouldRunAnalyze=false
. The build should succeed, but all the analyze steps should be skipped, and no files added into thecode_drop\TestResults\PSScriptAnalyzer
folderbuild.bat --shouldRunPSScriptAnalyzer=false
. The build should succeed, but all the analyze steps should be skipped, and no files added into thecode_drop\TestResults\PSScriptAnalyzer
folder, but other test results, for example, InspectCode, should be generated.Change Types Made
Related Issue
Fixes #32
Change Checklist