Skip to content

Commit f2cf5b9

Browse files
tablackburnclaude
andauthored
docs(build): clarify PowerShellBuild bug-workaround status (#32)
* docs(build): clarify PowerShellBuild bug-workaround status Three comment blocks in build.psake.ps1 referenced PowerShellBuild v0.7.3 bugs as "until bug is fixed" workarounds. Verified upstream status against PSB v0.8.0 (Feb 2026, latest) and updated the comments: 1. Coverage Threshold = 0 was framed as "until truncation bug is fixed." Reality: the truncation bug in Test-PSBuildPester.ps1:118 is display-only — the JaCoCo XML on disk has correct numbers and Codecov reads that. Threshold = 0 here is just to keep the local build from acting on the bogus 0% console display, the same "Codecov enforces threshold" pattern the upstream template uses. Reframed accordingly. 2. The custom ScriptAnalysis task (substitute for PSB's Test-PSBuildScriptAnalysis with its "$_Severity" typo) is still genuinely necessary — bug confirmed still in v0.8.0; no upstream fix PR open (only #106, which adds tests for the function). Updated version reference from 0.7.3 to v0.8.0 and noted the absence of a fix PR. No code change; just clarifying the rationale. Related to the multi-repo coverage-config alignment work in tablackburn/PowerShellModuleTemplate#19 and downstream PRs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(build): expand PSB and PR abbreviations in comments --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ac2c994 commit f2cf5b9

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

build.psake.ps1

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,20 @@ properties {
2525
$PSBPreference.Test.CodeCoverage.OutputFile = '../coverage.xml'
2626
$PSBPreference.Test.CodeCoverage.OutputFormat = 'JaCoCo'
2727
$PSBPreference.Test.CodeCoverage.Files = '../ScheduledTasksManager/**/*.ps1'
28-
# WORKAROUND: PowerShellBuild 0.7.3 has a bug in Test-PSBuildPester.ps1 line 118
29-
# It uses [Math]::Truncate([int]$_.covered / $total) which truncates 0.886 to 0
30-
# instead of 88.6%. Setting threshold to 0 until bug is fixed.
31-
# See: https://github.com/psake/PowerShellBuild/issues (bug reported)
28+
# Coverage threshold is enforced by Codecov, not by the local build.
29+
# PowerShellBuild's Test-PSBuildPester.ps1:118 has a [Math]::Truncate(int / int)
30+
# bug that displays sub-100% coverage as 0% on the console (still present in
31+
# v0.8.0). The bug is display-only — the JaCoCo XML written to disk has the
32+
# correct numbers and Codecov reads that XML, so coverage gating is unaffected.
33+
# Threshold = 0 here just prevents the local build from acting on the bogus
34+
# 0% display.
3235
$PSBPreference.Test.CodeCoverage.Threshold = 0.0
3336

34-
# PSScriptAnalyzer configuration (PowerShellBuild 0.7.3+)
35-
# Disable built-in analysis due to PowerShellBuild 0.7.3 bug:
36-
# Test-PSBuildScriptAnalysis.ps1 line 32-34 has typo "$_Severity" instead of "$_.Severity"
37-
# causing null reference exception. We use a custom ScriptAnalysis task until fixed.
37+
# Disable PowerShellBuild's built-in PSScriptAnalyzer integration.
38+
# Test-PSBuildScriptAnalysis.ps1:32-34 has a "$_Severity" typo (missing dot)
39+
# that silently misses findings — bug still present in v0.8.0; no upstream
40+
# fix pull request open (only #106, which adds tests for the function). The custom
41+
# ScriptAnalysis task below substitutes for it.
3842
$PSBPreference.Test.ScriptAnalysis.Enabled = $false
3943
$PSBPreference.Test.ScriptAnalysis.SettingsPath = Join-Path -Path $PSScriptRoot -ChildPath 'PSScriptAnalyzerSettings.psd1'
4044
}
@@ -109,9 +113,9 @@ Task -Name 'UnitTest' -Depends 'Build' -PreCondition $unitTestPreReqs -Descripti
109113
}
110114
}
111115

112-
# Custom ScriptAnalysis task to work around PowerShellBuild 0.7.3 bug
113-
# Bug: Test-PSBuildScriptAnalysis.ps1 uses "$_Severity" instead of "$_.Severity" (missing dot)
114-
# This causes null reference exception when PSScriptAnalyzer returns results
116+
# Custom ScriptAnalysis task — substitute for PowerShellBuild's
117+
# Test-PSBuildScriptAnalysis (the "$_Severity" typo, missing dot, that silently
118+
# drops findings). Bug still present in v0.8.0.
115119
$scriptAnalysisPreReqs = {
116120
$result = $true
117121
if (-not (Get-Module -Name PSScriptAnalyzer -ListAvailable)) {

0 commit comments

Comments
 (0)