You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Test-PSBuildScriptAnalysis never fails the build: $_Severity should be $_.Severity #125
Test-PSBuildScriptAnalysis counts analyzer findings by severity using $_Severity
(an undefined variable) instead of $_.Severity (the property). Every count is
therefore always 0, so the function — and the psake/Invoke-Build Analyze task that
calls it — never throws, regardless of findings. PSScriptAnalyzer enforcement is
silently disabled for every consumer relying on the Analyze task.
$_Severity is parsed as the variable $_Severity (which does not exist → $null), not
as the Severity property of the pipeline item $_. $null -eq 'Error' is $false for
every record, so .where({...}) always returns an empty collection and .Count is 0.
The downstream gate is then dead code:
if ($errors-gt0) { throw ... } # never trueif ($errors-gt0-or$warnings-gt0) { throw ... } # never true
Impact
Any project whose build relies on the Analyze task believes PSScriptAnalyzer is
gating its build, when in fact violations of any severity (including Error) pass.
Affects both the psake (psakeFile.ps1) and Invoke-Build (IB.tasks.ps1) task wrappers,
since both call Test-PSBuildScriptAnalysis.
Affected versions
Confirmed present in every published version on the PowerShell Gallery (0.1.0 through 0.8.0, the current latest) and on the main branch. Not version-specific.
Tests: Test-PSBuildScriptAnalysis #96 (adding unit tests for Test-PSBuildScriptAnalysis): a test that feeds the function a
result set containing an Error record and asserts it throws at SeverityThreshold = 'Error'
would have caught this and would guard against recurrence.
Fixed by #143 (merged as 64b7207). Verified against main: grep -rn '_Severity' PowerShellBuild/ returns no matches — Test-PSBuildScriptAnalysis now reads $_.Severity and the severity gate fails the build as intended.
The related gaps this bug was hiding — ParseError findings escaping every threshold, and the documented-but-rejected 'Any' value — are tracked separately in #144.
Activity
fix: enforce PSScriptAnalyzer in the build and drop the redundant lin…
fix: enforce PSScriptAnalyzer in the build and drop the redundant lin…
fix: enforce PSScriptAnalyzer in the build and drop the redundant lin…
fix: enforce PSScriptAnalyzer in the build and drop the redundant lin…
tablackburn commentedon Aug 20, 2026
Fixed by #143 (merged as
64b7207). Verified againstmain:grep -rn '_Severity' PowerShellBuild/returns no matches —Test-PSBuildScriptAnalysisnow reads$_.Severityand the severity gate fails the build as intended.The related gaps this bug was hiding —
ParseErrorfindings escaping every threshold, and the documented-but-rejected'Any'value — are tracked separately in #144.Closed during v1.0.0 route charting (#120).