Skip to content

Add -ErrorOnFinding so a multi-pass run cannot report false success - #18

Closed
thisjustin816 wants to merge 1 commit into
mainfrom
feature/analyzer-error-on-finding
Closed

thisjustin816 wants to merge 1 commit into
mainfrom
feature/analyzer-error-on-finding

Conversation

@thisjustin816

Copy link
Copy Markdown
Owner

-EnableExit sets the process exit code and lets the caller keep going, and the code is
last-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:

--- failing pass ---   2 rule violations found.
--- clean pass after it ---   0 rule violations found.
=== child exit code: 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

Consumers currently hand-rolling this (collect with -NoExit, test the result, throw) can drop that
wrapper. 74 tests pass; src is analyzer-clean.

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
@github-actions

Copy link
Copy Markdown

Test Results

74 tests  +3   74 ✅ +3   24s ⏱️ +7s
18 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit b74c6b1. ± Comparison against base commit 734de98.

@github-actions

Copy link
Copy Markdown

Summary

Summary
Generated on: 7/28/2026 - 8:23:28 PM
Coverage date: 7/28/2026 - 8:22:02 PM
Parser: JaCoCo
Assemblies: 2
Classes: 11
Files: 11
Line coverage: 91.4% (301 of 329)
Covered lines: 301
Uncovered lines: 28
Coverable lines: 329
Total lines: 1057
Covered branches: 0
Total branches: 0
Method coverage: Feature is only available for sponsors
Tag: 109_30395962993

Coverage

src/Private - 94.8%
Name Line Branch
src/Private 94.8% ****
src/Private/Get-PSModuleAnalyzerSettingsPath 100%
src/Private/Get-PSModuleGitMetadata 96%
src/Private/Get-PSModulePublishedManifest 100%
src/Private/Invoke-PSModuleAnalyzerCasingWorkaround 93.6%
src/Private/Resolve-PSModuleGitRemote 93.8%
src/Public - 89.1%
Name Line Branch
src/Public 89.1% ****
src/Public/Build-PSModule 77.9%
src/Public/Export-PSModuleAnalyzerSettings 84.2%
src/Public/Invoke-PSModuleAnalyzer 100%
src/Public/New-PSModuleManifest 97.6%
src/Public/Publish-PSModule 100%
src/Public/Test-PSModule 100%

@thisjustin816

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant