Return diagnostics instead of exiting, matching Invoke-ScriptAnalyzer - #19
Merged
Merged
Conversation
Invoke-ScriptAnalyzer returns diagnostics and treats -EnableExit as opt-in for CI. This wrapper had it backwards: EnableExit was the default and -NoExit undid it. That default is unusable as a gate, because SetShouldExit does not stop the caller and the code is last-writer-wins, so a clean pass after a failing one leaves the run reporting success. - Return diagnostics by default; the caller decides what a finding means - Replace -NoExit with -EnableExit, passed straight through with PSScriptAnalyzer's semantics - Bump to 4.0.0, since the default behavior changed and a parameter was removed Nothing on PSGallery is affected: AzDOCmd, JBUtils, and this module all call it with -Fix, which never set an exit code. reusable-workflows/ps-scriptAnalyzer.yml passes -NoExit and is pinned to PSModuleUtils 2.*, so it needs a matching update before the pin moves.
SummarySummary
Coveragesrc/Private - 94.8%
src/Public - 88.8%
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Invoke-ScriptAnalyzerreturns diagnostics and treats-EnableExitas opt-in for CI. This wrapperhad it backwards —
EnableExitwas the default and-NoExitundid it:Invoke-ScriptAnalyzerInvoke-PSModuleAnalyzerbeforeSetShouldExit(count)-EnableExit, opt in-NoExitThat default cannot gate a build.
SetShouldExitis a request to the host, so it neither stops thecaller nor survives a later pass — a 2-finding pass followed by a clean pass exits
0:-NoExitwith-EnableExit, passed straight through with PSScriptAnalyzer's semanticsCompatibility. Nothing on PSGallery is affected — AzDOCmd, JBUtils, and this module all call it
with
-Fix, which never set an exit code. The one coupling isreusable-workflows/ps-scriptAnalyzer.yml, which passes-NoExitand is pinned to PSModuleUtils2.*; it needs-NoExitdropped and the pin raised, which also unblocks its own PSScriptAnalyzercheck on this PR.
72 tests pass;
srcis analyzer-clean.