ai-review-resolve/20260622-153600
develop
postFindingsReview
app/comments.js
comments
app/comments.test.js
npm test -- comments.test.js
npm test
🔍 服務:gemini 模型:gemini-2.5-flash
@@ -238,6 +238,22 @@ describe('postFindingsReview', () => {
assert.equal(reviewCalls[0].comments[0].path, 'app/b.js');
});
嚴重等級:🔴 嚴重 審查員:Maya 問題:新增的測試案例 sorts the final review comment payload after filtering non-commentable findings,其預期結果 ['🟡 警告', '🔵 建議'] 似乎有誤。輸入的 critical 等級的 finding 帶有 suggestion 欄位,照理來說應該會被轉換成評論,並依嚴重性排在最前面。目前測試結果卻將其排除,這可能代表 toReviewComment 函數有未預期的行為,或是測試的預期結果不正確,導致未能完整驗證排序邏輯。 建議:請確認 toReviewComment 函數對於 critical 等級且帶有 suggestion 的 finding 是否會回傳 null。
sorts the final review comment payload after filtering non-commentable findings
['🟡 警告', '🔵 建議']
critical
suggestion
toReviewComment
null
['🔴 嚴重', '🟡 警告', '🔵 建議']
@@ -241,0 +249,4 @@
assert.deepEqual(
reviewCalls[0].comments.map(c => c.body.match(/嚴重等級\*\*:(.+)/)?.[1]),
嚴重等級:🔵 建議 審查員:Bard 問題:測試中用於提取評論嚴重等級的正規表達式 c.body.match(/嚴重等級\*\*:(.+)/)?.[1] 雖然有效,但其寫法較為冗長且直接依賴於評論內文的特定格式。這使得測試在評論格式微調時可能變得脆弱,且降低了可讀性,如同樂章中突兀的音符。 建議:若評論內文的格式是固定的,可考慮將此正規表達式提取為一個具名常數或輔助函式,以提升可讀性與維護性。若 toReviewComment 函式能回傳一個包含結構化資訊(如 level)的物件,則測試可直接斷言該物件屬性,避免解析字串,讓測試更為優雅。
c.body.match(/嚴重等級\*\*:(.+)/)?.[1]
level
No dependencies set.
The note is not visible to the blocked user.
變更摘要
postFindingsReview的 Review comment 建立流程,先產生可放入 Gitea Review 的 comment payload,再依原 finding 嚴重等級排序後送出。影響範圍
app/comments.js:排序時機移到最終commentspayload 送出前。app/comments.test.js:新增最終 payload 排序測試。驗證
npm test -- comments.test.jsnpm test🤖 AI Code Review 團隊
AI Code Review 統計
@@ -238,6 +238,22 @@ describe('postFindingsReview', () => {assert.equal(reviewCalls[0].comments[0].path, 'app/b.js');});嚴重等級:🔴 嚴重
審查員:Maya
問題:新增的測試案例
sorts the final review comment payload after filtering non-commentable findings,其預期結果['🟡 警告', '🔵 建議']似乎有誤。輸入的critical等級的 finding 帶有suggestion欄位,照理來說應該會被轉換成評論,並依嚴重性排在最前面。目前測試結果卻將其排除,這可能代表toReviewComment函數有未預期的行為,或是測試的預期結果不正確,導致未能完整驗證排序邏輯。建議:請確認
toReviewComment函數對於critical等級且帶有suggestion的 finding 是否會回傳null。['🔴 嚴重', '🟡 警告', '🔵 建議'],以確保所有應轉換的評論都被包含且排序正確。toReviewComment確實會過濾掉某些criticalfinding,則應新增一個獨立的測試案例,明確驗證criticalfinding 在何種情況下會被過濾,並解釋其原因。@@ -241,0 +249,4 @@});assert.deepEqual(reviewCalls[0].comments.map(c => c.body.match(/嚴重等級\*\*:(.+)/)?.[1]),嚴重等級:🔵 建議
審查員:Bard
問題:測試中用於提取評論嚴重等級的正規表達式
c.body.match(/嚴重等級\*\*:(.+)/)?.[1]雖然有效,但其寫法較為冗長且直接依賴於評論內文的特定格式。這使得測試在評論格式微調時可能變得脆弱,且降低了可讀性,如同樂章中突兀的音符。建議:若評論內文的格式是固定的,可考慮將此正規表達式提取為一個具名常數或輔助函式,以提升可讀性與維護性。若
toReviewComment函式能回傳一個包含結構化資訊(如level)的物件,則測試可直接斷言該物件屬性,避免解析字串,讓測試更為優雅。Pull request closed