Skip to content

Return diagnostics instead of exiting, matching Invoke-ScriptAnalyzer - #19

Merged
thisjustin816 merged 1 commit into
mainfrom
feature/analyzer-returns-diagnostics
Jul 28, 2026
Merged

thisjustin816 merged 1 commit into
mainfrom
feature/analyzer-returns-diagnostics

Conversation

@thisjustin816

Copy link
Copy Markdown
Owner

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:

Invoke-ScriptAnalyzer Invoke-PSModuleAnalyzer before
Default returns diagnostics SetShouldExit(count)
CI exit code -EnableExit, opt in the default
Opt out n/a -NoExit

That default cannot gate a build. SetShouldExit is a request to the host, so it neither stops the
caller nor survives a later pass — 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 ===
  • Return diagnostics by default; the caller decides what a finding means
  • Replace -NoExit with -EnableExit, passed straight through with PSScriptAnalyzer's semantics
  • 4.0.0, since the default changed and a parameter was removed

Compatibility. Nothing on PSGallery is affected — AzDOCmd, JBUtils, and this module all call it
with -Fix, which never set an exit code. The one coupling is
reusable-workflows/ps-scriptAnalyzer.yml, which passes -NoExit and is pinned to PSModuleUtils
2.*; it needs -NoExit dropped and the pin raised, which also unblocks its own PSScriptAnalyzer
check on this PR.

72 tests pass; src is analyzer-clean.

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

Copy link
Copy Markdown

Test Results

72 tests  +1   72 ✅ +1   18s ⏱️ -1s
18 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 811b376. ± Comparison against base commit 734de98.

@github-actions

Copy link
Copy Markdown

Summary

Summary
Generated on: 7/28/2026 - 8:49:38 PM
Coverage date: 7/28/2026 - 8:47:35 PM
Parser: JaCoCo
Assemblies: 2
Classes: 11
Files: 11
Line coverage: 91.3% (296 of 324)
Covered lines: 296
Uncovered lines: 28
Coverable lines: 324
Total lines: 1050
Covered branches: 0
Total branches: 0
Method coverage: Feature is only available for sponsors
Tag: 110_30397786261

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 - 88.8%
Name Line Branch
src/Public 88.8% ****
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
thisjustin816 merged commit 0d9029f into main Jul 28, 2026
2 of 3 checks passed
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