Skip to content

fix: keep the readiness section visible when nothing can be assessed - #8

Merged
lis186 merged 1 commit into
mainfrom
fix/readiness-empty-assessment
Jul 30, 2026
Merged

fix: keep the readiness section visible when nothing can be assessed#8
lis186 merged 1 commit into
mainfrom
fix/readiness-empty-assessment

Conversation

@lis186

@lis186 lis186 commented Jul 30, 2026

Copy link
Copy Markdown
Owner

變更說明

Closes #4

整個「發布準備度分析」區塊被 freezePeriodAssessment.length > 0 守衛,而 summary.recommendation 就在那個 if 之內。沒有可評估的發布時整段從報告消失,使用者不會知道它為什麼不見了——而 analyzer 端早就備好了這個情況要用的句子 '無足夠資料進行評估',只是永遠印不出來。

0 筆以前很罕見,現在是常見路徑:凍結期評估會跳過沒有測量基準的發布(無前一個標籤,或區間內 0 筆 MR),所以查詢範圍只涵蓋一個 major、或所有 major 都缺基準時就是 0 筆。

比 issue 描述多做的一件事

issue 說「把守衛降到個別評估那層,摘要照印」。實作時發現摘要不能照印:0 筆時那三行會變成

  分析發布數:0 次
  平均凍結期:0.0 天          ← 沒有樣本,不是量到 0 天
  健康評級:0 健康 / 0 警告 / 0 危險

「平均凍結期 0.0 天」會被讀成實測值,而這正是這個區域已經修過兩次的「未知當零」。所以 0 筆時只印區塊標題與說明,不印任何數字:

發布準備度分析(凍結期健康評估)
───────────────────────────────────────────────

準備度摘要
  → 無足夠資料進行評估

有可評估發布時完全照舊。

安全性檢查清單

  • 我已確認沒有提交任何敏感資訊(tokens, passwords, 內部 URLs)
  • 我已確認沒有包含真實的公司/專案名稱
  • 我已使用 .env 管理所有配置資訊
  • 我已執行 ./scripts/check-secrets.sh 並通過檢查
  • 我已執行測試並通過:npm test

測試 fixture 用 group/projectv1.1.0 等通用值。

測試計畫

npx tsc --noEmit                          # 0 錯誤
npx vitest run --no-file-parallelism      # 82 檔 / 1197 passed / 16 skipped(原 1192)

src/formatters/release-analysis-formatter.ts 原本沒有任何單元測試,所以舊 bug 與這次修復都不會被既有測試抓到。新增 tests/unit/formatters/release-analysis-formatter-readiness.test.ts(5 個測試),涵蓋修復的兩半與兩個不該變的行為:

測試 釘住什麼
0 筆時仍印出區塊與說明 修復的前半(不得消失)
0 筆時不得印平均凍結期/健康評級/分析發布數 修復的後半(不得印假數字)
有可評估發布時照原樣印出摘要數字 防過度抑制
有問題的發布仍列在「需要關注的發布」下 個別評估未受影響
沒有 readiness 資料時不印這個區塊 向後相容

突變測試:

突變 結果
守衛改回 length > 0 1 紅(「不得消失」那條)
0 筆時也照印數字 1 紅(「不得印假數字」那條)

兩半各自獨立轉紅,確認不是靠同一條斷言撐著。

相關 Issue

Closes #4

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>
@lis186
lis186 merged commit 3227bb2 into main Jul 30, 2026
1 check failed
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.

readiness 區塊在 0 筆評估時整段消失,「無足夠資料進行評估」永遠印不出來

1 participant