PSScriptAnalyzer
PSScriptAnalyzer copied to clipboard
Set Invoke-ScriptAnalyzer Path default value
PR Summary
Removes Path
as a mandatory parameter and sets the default to the current working directory.
Resolves #1887
PR Checklist
- [x] PR has a meaningful title
- Use the present tense and imperative mood when describing your changes
- [x] Summarized changes
- [x] Change is not breaking
- [x] Make sure all
.cs
,.ps1
and.psm1
files have the correct copyright header - [ ] Make sure you've added a new test if existing tests do not effectively test the code changed and/or updated documentation
- [ ] This PR is ready to merge and is not Work in Progress.
- If the PR is work in progress, please add the prefix
WIP:
to the beginning of the title and remove the prefix when the PR is ready.
- If the PR is work in progress, please add the prefix
Nice idea but you'd need to fix existing tests
I'm not sure why the tests are failing with change as the tests would be using a provided path and not a default.
I will try look into it another time and see whether I can do something about it, definitely before next release, sorry it's taken so long
@ThomasNieto This seems like a good idea to me 🙂
@bergmeister, This fails many of the tests as the path now always has some value. If -ScriptDefinition
is supplied - it's ignored
https://github.com/PowerShell/PSScriptAnalyzer/blob/ab1dd25ccf266c6798d8c63c91f7e7c451790c4e/Engine/Commands/InvokeScriptAnalyzerCommand.cs#L433
https://github.com/PowerShell/PSScriptAnalyzer/blob/ab1dd25ccf266c6798d8c63c91f7e7c451790c4e/Engine/Commands/InvokeScriptAnalyzerCommand.cs#L526
You should probably make a change to the IsFileParameterSet()
function to instead check that ScriptDefinition doesn't have some value. Or maybe better still return this.ParameterSetName.StartsWith("Path")
.
You will also need to update the markdown help file for Invoke-ScriptAnalyzer
to tell the help system that path is no longer required:
https://github.com/PowerShell/PSScriptAnalyzer/blob/a0365a56068f711ee1ec08fae11a85fcc1542f8c/docs/Cmdlets/Invoke-ScriptAnalyzer.md?plain=1#L391
Or you'll get a test failure from Tests\Engine\ModuleHelp.Tests.ps1
https://github.com/PowerShell/PSScriptAnalyzer/blob/a0365a56068f711ee1ec08fae11a85fcc1542f8c/Tests/Engine/ModuleHelp.Tests.ps1#L229
Hope that helps 😀!