PSScriptAnalyzer icon indicating copy to clipboard operation
PSScriptAnalyzer copied to clipboard

Set Invoke-ScriptAnalyzer Path default value

Open ThomasNieto opened this issue 2 years ago • 4 comments

PR Summary

Removes Path as a mandatory parameter and sets the default to the current working directory.

Resolves #1887

PR Checklist

ThomasNieto avatar Feb 14 '23 23:02 ThomasNieto

Nice idea but you'd need to fix existing tests

bergmeister avatar Sep 17 '23 18:09 bergmeister

I'm not sure why the tests are failing with change as the tests would be using a provided path and not a default.

ThomasNieto avatar Sep 17 '23 18:09 ThomasNieto

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

bergmeister avatar Sep 17 '23 21:09 bergmeister

@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 😀!

liamjpeters avatar Mar 27 '24 08:03 liamjpeters