fix: keep the readiness section visible when nothing can be assessed - #8
Merged
Conversation
The whole "release readiness" section was wrapped in `freezePeriodAssessment.length > 0`, and `summary.recommendation` sat inside that guard. With no assessable release the section vanished from the report entirely, giving the reader no hint why — while the analyzer had already prepared the exact sentence for this case, "無足夠資料進行評估", which could never be printed. Zero assessments used to be rare. It is now a normal path: freeze-period assessment skips releases with no measurement baseline (no predecessor tag, or no MRs in range), so a query covering a single major — or one where every major lacks a baseline — produces none. The section now always renders when readiness data exists, but the numeric summary is suppressed at zero. Printing "平均凍結期 0.0 天" and "0 健康 / 0 警告 / 0 危險" would state sample-less zeros as if they were measurements, which is the same "unknown rendered as zero" failure this area has been fixed for twice already. At zero the section shows the header and the explanation, nothing more. This file had no unit tests at all, so neither the old bug nor this fix would have been caught by the suite. Added coverage for both halves — the section must appear at zero, and it must not print fabricated numbers there — plus the non-empty path and the case where readiness data is absent entirely. Mutation-tested: restoring the old guard fails one test, printing the numbers at zero fails another. Closes #4 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
變更說明
Closes #4。
整個「發布準備度分析」區塊被
freezePeriodAssessment.length > 0守衛,而summary.recommendation就在那個if之內。沒有可評估的發布時整段從報告消失,使用者不會知道它為什麼不見了——而 analyzer 端早就備好了這個情況要用的句子'無足夠資料進行評估',只是永遠印不出來。0 筆以前很罕見,現在是常見路徑:凍結期評估會跳過沒有測量基準的發布(無前一個標籤,或區間內 0 筆 MR),所以查詢範圍只涵蓋一個 major、或所有 major 都缺基準時就是 0 筆。
比 issue 描述多做的一件事
issue 說「把守衛降到個別評估那層,摘要照印」。實作時發現摘要不能照印:0 筆時那三行會變成
「平均凍結期 0.0 天」會被讀成實測值,而這正是這個區域已經修過兩次的「未知當零」。所以 0 筆時只印區塊標題與說明,不印任何數字:
有可評估發布時完全照舊。
安全性檢查清單
.env管理所有配置資訊./scripts/check-secrets.sh並通過檢查npm test測試 fixture 用
group/project、v1.1.0等通用值。測試計畫
src/formatters/release-analysis-formatter.ts原本沒有任何單元測試,所以舊 bug 與這次修復都不會被既有測試抓到。新增tests/unit/formatters/release-analysis-formatter-readiness.test.ts(5 個測試),涵蓋修復的兩半與兩個不該變的行為:突變測試:
length > 0兩半各自獨立轉紅,確認不是靠同一條斷言撐著。
相關 Issue
Closes #4