docs(ai-review 註解): 收斂註解與腳本雜訊
This commit is contained in:
+9
-21
@@ -235,28 +235,16 @@ function toReviewComment(f) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 發布單一 Gitea review:一次性送出「統計摘要 + 逐筆行內 review comment」,並提供多層降級機制。
|
||||
*
|
||||
* @param {Array<object>} findings 本次審查的完整 findings 陣列;當 `deps.summaryFindings` 或
|
||||
* `deps.commentFindings` 未提供時,兩者皆預設使用此參數。
|
||||
* @param {object} [deps={}] 可覆寫的相依注入物件(主要供測試替換,正常情境可省略)。
|
||||
* @param {Function} [deps.postReview=postPullReview] 發布整批 review(含 body 與 comments)的函式。
|
||||
* @param {Function} [deps.postInline=postPullReviewComment] 發布單筆行內 review comment 的函式。
|
||||
* @param {Function} [deps.postIssue=postComment] 發布一般(非 review)comment 的函式,作為最終降級手段。
|
||||
* @param {Array<object>} [deps.summaryFindings=findings] 用於統計本文數字(含新舊問題)的 findings 子集合。
|
||||
* @param {Array<object>} [deps.commentFindings=findings] 用於產生 review comments 的 findings 子集合;
|
||||
* 會先依 {@link bySeverity} 排序,僅新問題(`is_new !== false`)會被轉成行內 comment,
|
||||
* 舊問題只計入統計、不再重複標註檔案與行數。
|
||||
* @param {string} [deps.usageSection=''] 附加在統計表之後的用量/token 統計區塊;空字串時不附加。
|
||||
* 發布單一 Gitea review,必要時會先降級成 summary review,再降級成一般 comment。
|
||||
* @param {Array<object>} findings 審查 findings。
|
||||
* @param {object} [deps={}] 可注入的相依物件。
|
||||
* @param {Function} [deps.postReview=postPullReview] 發布整批 review 的函式。
|
||||
* @param {Function} [deps.postInline=postPullReviewComment] 發布單筆行內 comment 的函式。
|
||||
* @param {Function} [deps.postIssue=postComment] 發布一般 comment 的降級函式。
|
||||
* @param {Array<object>} [deps.summaryFindings=findings] 用於統計的 findings 子集合。
|
||||
* @param {Array<object>} [deps.commentFindings=findings] 用於建立 review comments 的 findings 子集合。
|
||||
* @param {string} [deps.usageSection=''] 附加的使用量區塊。
|
||||
* @returns {Promise<void>} 無回傳值。
|
||||
* @remarks
|
||||
* 降級順序:① 整批 `postReview`(含 comments)→ 失敗則 ② 僅 body 的 `postReview`
|
||||
* (comments 為空陣列)→ 失敗則 ③ `postIssue(body)`。**注意:③ 未包在 try/catch 中**,
|
||||
* 若 `postIssue` 本身失敗,例外會直接從本函式往外拋出(reject),呼叫端須自行 catch。
|
||||
* 無論走到哪一步,只要走完 ①~③ 中任一步不再往下失敗,後續都會逐筆嘗試 `postInline` 補發
|
||||
* 行內 comment,每筆各自失敗僅記錄 warn 並略過,不影響其他筆。
|
||||
* 使用情境:CI 流程完成一輪 AI Code Review 後,呼叫一次本函式即可把整批結果發布到 Gitea PR;
|
||||
* 單元測試時可透過 `deps` 注入假的 `postReview`/`postInline`/`postIssue` 以驗證各降級分支。
|
||||
*/
|
||||
export async function postFindingsReview(findings, deps = {}) {
|
||||
const {
|
||||
|
||||
Reference in New Issue
Block a user