From 71c9b40c0bace938daae4c3dfb20014f76733801 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 22 Jun 2026 10:07:24 +0000 Subject: [PATCH] =?UTF-8?q?style(ai-review=20=E7=B5=B1=E8=A8=88):=20?= =?UTF-8?q?=E6=94=B9=E7=94=A8=E4=B8=89=E6=AC=84=E5=85=A9=E8=A1=8C=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/comments.js | 13 +++++++------ app/comments.test.js | 12 ++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/comments.js b/app/comments.js index 3ee6e84..942cec1 100644 --- a/app/comments.js +++ b/app/comments.js @@ -62,15 +62,16 @@ function countBy(findings, predicate) { function buildReviewSummary(findings, commentable) { const unplacedCount = findings.length - commentable.length; + const criticalCount = countBy(findings, f => f.level === 'critical'); + const warningCount = countBy(findings, f => f.level === 'warning'); + const infoCount = countBy(findings, f => f.level === 'info'); return [ '## AI Code Review 統計', '', - `總問題:${findings.length} 筆`, - `可標註檔案與行數:${commentable.length} 筆`, - `無法標註檔案與行數:${unplacedCount} 筆`, - `嚴重:${countBy(findings, f => f.level === 'critical')} 筆`, - `警告:${countBy(findings, f => f.level === 'warning')} 筆`, - `建議:${countBy(findings, f => f.level === 'info')} 筆`, + '| 統計 | 統計 | 統計 |', + '| --- | --- | --- |', + `| **總問題**
${findings.length} 筆 | **可標註檔案與行數**
${commentable.length} 筆 | **無法標註檔案與行數**
${unplacedCount} 筆 |`, + `| **🔴 嚴重**
${criticalCount} 筆 | **🟡 警告**
${warningCount} 筆 | **🔵 建議**
${infoCount} 筆 |`, ].join('\n'); } diff --git a/app/comments.test.js b/app/comments.test.js index 7e3b88a..f21b16d 100644 --- a/app/comments.test.js +++ b/app/comments.test.js @@ -200,11 +200,9 @@ describe('postFindingsReview', () => { }); assert.equal(reviewCalls.length, 1); - assert.match(reviewCalls[0].body, /總問題:3 筆/); - assert.match(reviewCalls[0].body, /可標註檔案與行數:3 筆/); - assert.match(reviewCalls[0].body, /嚴重:1 筆/); - assert.match(reviewCalls[0].body, /警告:1 筆/); - assert.match(reviewCalls[0].body, /建議:1 筆/); + assert.match(reviewCalls[0].body, /\| 統計 \| 統計 \| 統計 \|/); + assert.match(reviewCalls[0].body, /\| \*\*總問題\*\*
3 筆 \| \*\*可標註檔案與行數\*\*
3 筆 \| \*\*無法標註檔案與行數\*\*
0 筆 \|/); + assert.match(reviewCalls[0].body, /\| \*\*🔴 嚴重\*\*
1 筆 \| \*\*🟡 警告\*\*
1 筆 \| \*\*🔵 建議\*\*
1 筆 \|/); assert.deepEqual( reviewCalls[0].comments.map(c => c.path), ['app/a.js', 'app/b.js', 'app/c.js'], @@ -229,9 +227,7 @@ describe('postFindingsReview', () => { }); assert.equal(reviewCalls.length, 1); - assert.match(reviewCalls[0].body, /總問題:2 筆/); - assert.match(reviewCalls[0].body, /可標註檔案與行數:1 筆/); - assert.match(reviewCalls[0].body, /無法標註檔案與行數:1 筆/); + assert.match(reviewCalls[0].body, /\| \*\*總問題\*\*
2 筆 \| \*\*可標註檔案與行數\*\*
1 筆 \| \*\*無法標註檔案與行數\*\*
1 筆 \|/); assert.equal(reviewCalls[0].comments.length, 1); assert.equal(reviewCalls[0].comments[0].path, 'app/b.js'); });