Add -ErrorOnFinding so a multi-pass run cannot report false success - #18
Closed
thisjustin816 wants to merge 1 commit into
Closed
thisjustin816 wants to merge 1 commit into
thisjustin816 wants to merge 1 commit into
Conversation
PSScriptAnalyzer's -EnableExit sets the process exit code and lets the caller keep going, and the code is last-writer-wins. A script that analyzes several paths therefore reports success whenever a clean pass follows a failing one, which makes the default mode unusable as a gate. Verified: a 2-finding pass followed by a clean pass exits 0. - Add -ErrorOnFinding, which suppresses EnableExit and throws with the count and the path - Print the diagnostics before throwing, since the throw discards the records themselves - Leave the streaming path untouched so the declared OutputType still describes what comes back - Bump the module to 3.2.0
SummarySummary
Coveragesrc/Private - 94.8%
src/Public - 89.1%
|
Owner
Author
|
Superseded by the 4.0.0 approach: rather than adding a third mode, Invoke-PSModuleAnalyzer now returns diagnostics like Invoke-ScriptAnalyzer does, and -EnableExit becomes an opt-in pass-through. |
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.
-EnableExitsets the process exit code and lets the caller keep going, and the code islast-writer-wins. Any script that analyzes several paths in one process therefore reports success
whenever a clean pass follows a failing one, so the default mode cannot be used as a gate.
Verified against the real analyzer — a 2-finding pass followed by a clean pass exits
0:-ErrorOnFinding, which suppressesEnableExitand throws with the count and the pathOutputTypestill describes what comes backConsumers currently hand-rolling this (collect with
-NoExit, test the result, throw) can drop thatwrapper. 74 tests pass;
srcis analyzer-clean.