chore: add additional exclusions for N+1 issues and improve test coverage

This commit is contained in:
2026-05-15 06:28:44 +00:00
parent a6ae2ed48d
commit 589f4fc536
+15
View File
@@ -20,6 +20,21 @@
"location": "entrypoint.sh:176",
"title": "collect_package_candidates N+1 (explicit)",
"reason": "在 collect_package_candidates 函數中,程式碼從原本一次性獲取所有 NuGet 套件資訊(透過 fetch_all_pages 呼叫 /api/v1/packages/${REPO_OWNER}?type=nuget),改為針對 INPUT_PACKAGE_NAMES 中的每個套件名逐一呼叫 fetch_package_versions。若 INPUT_PACKAGE_NAMES 包含大量套件,這會導致大量獨立的 API 請求(N 個套件 * N 頁面),顯著增加網路延遲與 Gitea 伺服器負載,並且可能造成執行時間大幅增加。建議:考慮恢復到原始的資料擷取策略,先一次或少次取得所有套件與版本,然後在本地進行過濾與分組,以減少 API 呼叫數量。"
},
{
"location": "entrypoint.sh",
"title": "log function definition unclear",
"reason": "腳本中廣泛使用了 `log` 函式,但此 diff 並未包含 `log` 的定義,表示 `log` 可能來自基礎映像或另一個未包含的腳本。建議:在 entrypoint.sh 明確定義 `log` 或在文件/腳本中註明其來源,提升可維護性與自包含性。"
},
{
"location": "entrypoint.sh:46",
"title": "resolve_token empty-token test suggestion",
"reason": "新增測試案例,驗證當 `RUNNER_TOKEN` 和 `INPUT_GITEA_TOKEN` 都為空時,`resolve_token` 函數會正確地失敗並輸出錯誤訊息。建議:加入單元測試覆蓋空 token 的情境,確保函數在無認證資訊時能安全終止並回報清晰錯誤。"
},
{
"location": "entrypoint.sh:91",
"title": "parse_repo_context invalid-input test suggestion",
"reason": "新增 `parse_repo_context` 的測試案例,驗證在以下無效輸入時會正確失敗:空字串或僅含空白字元、不含斜線的字串、包含多個斜線的字串、只有斜線的字串、只有 owner 或只有 repo 的字串。建議:為上述邊界與無效格式情境撰寫單元測試,以驗證解析函數的健壯性並確保在錯誤輸入時有明確行為。"
}
]
}