test(ai-review): 補使用量統計 NaN 安全測試並排除微優化誤報 #46

Merged
jiantw83 merged 14 commits from ai-review-resolve/20260623-163642 into develop 2026-06-23 09:35:21 +00:00
2 changed files with 7 additions and 18 deletions
Showing only changes of commit 1ff74297ce - Show all commits
+6
View File
@@ -518,5 +518,11 @@
"role": "Maya", "role": "Maya",
"original_finding": "parseBotReviewComment 的測試沒有驗證解析失敗時回傳 null 的行為。", "original_finding": "parseBotReviewComment 的測試沒有驗證解析失敗時回傳 null 的行為。",
"reason": "誤判,測試已存在。'returns null for free-form human comments' 已斷言自由格式留言、空字串、null 皆回傳 null。" "reason": "誤判,測試已存在。'returns null for free-form human comments' 已斷言自由格式留言、空字串、null 皆回傳 null。"
},
{
"location": "app/usage.js:146",
"role": "Rogue",
"original_finding": "在 recordRateLimit 中頻繁呼叫 lowerCaseKeys,對每個請求的 headers 複製與轉換,增加記憶體分配開銷;建議改用不分大小寫存取避免複製。",
"reason": "過度設計/非熱路徑。recordRateLimit 每次 LLM 回應只呼叫一次(一輪審查約 13 次),headers 物件小,複製成本可忽略;改用不分大小寫存取器反而增加複雜度,效益不成比例。"
} }
] ]
+1 -18
View File
@@ -1,18 +1 @@
[ []
{
"level": "warning",
"role": "Maya",
"location": "app/usage.test.js:240",
"problem": "`formatUsageStatsLine` 測試案例中,僅驗證了單一平台的格式,缺失了當 `quota` 或 `rate` 資料缺失或包含無效數字(如 `NaN`)時的處理測試。",
"suggestion": "補充針對 `quota` 或 `rate` 傳入異常資料(如 `limit: NaN`)的測試,驗證 `formatUsageStatsLine` 是否能產生安全的預設文字,而非輸出 `NaN` 或破壞版面。",
"is_new": true
},
{
"level": "warning",
"role": "Rogue",
"location": "app/usage.js:146",
"problem": "在 `recordRateLimit` 中頻繁呼叫 `lowerCaseKeys`,這會對每個請求的 headers 進行複製與轉換,增加記憶體分配開銷。",
"suggestion": "建議直接存取 headers 時改用不區分大小寫的存取函式,避免複製整個物件。",
"is_new": true
}
]