Files
code-review/.gitea/ai-review/findings.json
T
2026-05-12 03:48:43 +00:00

338 lines
15 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
[
{
"level": "critical",
"role": "Leo",
"location": "app/config.js:1",
"suggestion": "`getLLMConfig` 在找不到任何符合條件的 provider 時會回傳 `undefined`,而呼叫端(例如測試)假設會得到一個包含 `provider`、`apiKey`、`baseURL`、`model` 欄位的物件,導致執行時拋出 `TypeError`。請在函式結尾加入預設回傳值,例如 `return { provider: null, apiKey: null, baseURL: null, model: null };`,並在文件中說明此行為。",
"is_new": false
},
{
"level": "critical",
"role": "Aria",
"location": ".gitea/ai-review/exclusions.json",
"suggestion": "新增的條目包含 `role` 欄位,但目前的 JSON schema 只接受 `location` 與 `suggestion`,此欄位會導致驗證失敗,請移除或更新 schema。",
"is_new": false
},
{
"level": "critical",
"role": "Leo",
"location": "app/findings.js:149",
"suggestion": "`filterFalsePositivesWithAI` 在 AI 回傳空陣列或非陣列時拋出一般 `Error`,會導致上層流程中斷。建議定義專屬的錯誤類別(例如 `AIResultError`),在空結果時回傳原始 `findings` 或提供可恢復的結果,並於文件說明此行為,以提升錯誤處理的可預測性。",
"is_new": true
},
{
"level": "critical",
"role": "Rex",
"location": ".gitea/ai-review/exclusions.json:7",
"suggestion": "移除在 exclusions.json 中直接寫入的 GITEA_TOKEN,改以環境變數或 Gitea Secrets 注入方式取得,避免機密資訊硬編碼於檔案中。",
"is_new": true
},
{
"level": "critical",
"role": "Rex",
"location": "app/config.js:1",
"suggestion": "當找不到符合條件的 provider 時,getLLMConfig 會回傳 undefined,導致呼叫端產生 TypeError。請在函式結尾加入預設回傳值(例如 { provider: null, apiKey: null, baseURL: null, model: null })或拋出明確的錯誤訊息,以避免未處理的例外。",
"is_new": true
},
{
"level": "critical",
"role": "Aria",
"location": ".gitea/ai-review/exclusions.json:12",
"suggestion": "移除 `role` 欄位,JSON schema 只接受 `location` 與 `suggestion`,保留這兩個欄位即可,避免驗證失敗。",
"is_new": true
},
{
"level": "critical",
"role": "Aria",
"location": "app/config.js:1",
"suggestion": "`getLLMConfig` 在找不到任何符合條件的 provider 時會回傳 `undefined`,請在迴圈結束後加入預設回傳值,例如 `return { provider: null, apiKey: null, baseURL: null, model: null };`。",
"is_new": true
},
{
"level": "warning",
"role": "Leo",
"location": "app/config.js:5",
"suggestion": "目前使用硬編碼的 `checks` 陣列來管理所有 LLM provider,未來若要新增或移除 provider 必須直接修改程式碼,易產生重複與維護負擔。建議將 provider 設定抽離至外部 JSON/YAML 檔或使用可擴充的資料結構,並在程式中載入,提升模組化與可維護性。",
"is_new": false
},
{
"level": "warning",
"role": "Leo",
"location": "app/config.js:3",
"suggestion": "為 `getLLMConfig` 加上 JSDoc 或 TypeScript 型別註解,說明回傳物件的結構與每個欄位的意義,方便其他開發者快速了解 API,降低錯誤使用的風險。",
"is_new": false
},
{
"level": "warning",
"role": "Zara",
"location": "app/config.js",
"suggestion": "將 getLLMConfig 的結果快取(例如使用單例或 memoization),避免在程式執行期間多次重複遍歷 checks 陣列與讀取 process.env,減少不必要的 I/O 開銷。",
"is_new": false
},
{
"level": "warning",
"role": "Rex",
"location": ".gitea/workflows/review.yaml:33",
"suggestion": "工作流程目前授予 contents、pullrequests、issues 三項 write 權限,過於寬鬆。建議依實際需求僅授予 read 或最小必要的 write 權限,以降低被濫用的風險。",
"is_new": false
},
{
"level": "warning",
"role": "Rex",
"location": ".gitea/workflows/review.yaml:35",
"suggestion": "將 OPENAI_API_KEY 參數改為使用正確的 secret 名稱(如 OPENROUTER_API_KEY)時,請確保工作流程文件中不會同時暴露兩個不同的 secret 名稱,以免因名稱錯誤導致金鑰未傳入或意外洩漏。",
"is_new": false
},
{
"level": "warning",
"role": "Aria",
"location": ".gitea/workflows/review.yaml:33",
"suggestion": "在 `OPENAI_API_KEY` 後的註解前應保留一個空格,以符合常見的 YAML 註解風格:`... ${{ secrets.OPENROUTER_API_KEY }} # OpenRouter 使用 OpenAI 相容介面,以 OPENAI_API_KEY 傳入`。",
"is_new": false
},
{
"level": "warning",
"role": "Aria",
"location": "README.md",
"suggestion": "文件中章節編號不連續(例如 `### 2. OpenRouter` 後直接跳到 `### 3. Anthropic Claude`),建議重新編號或使用一致的標題層級,以提升可讀性與維護性。",
"is_new": false
},
{
"level": "warning",
"role": "Aria",
"location": "app/config.js",
"suggestion": "`checks` 陣列的每一行過長,超過 120 個字元,建議拆成多行並對齊欄位,以符合程式碼可讀性與行長限制的慣例。",
"is_new": false
},
{
"level": "warning",
"role": "Aria",
"location": "app/config.js",
"suggestion": "`amazonq` 那一行的空格對齊與其他項目不一致,請統一使用單一個空格分隔欄位,或使用對齊工具保持列的垂直對齊。",
"is_new": false
},
{
"level": "warning",
"role": "Leo",
"location": "app/config.js:12",
"suggestion": "目前使用硬編碼的 `checks` 陣列管理所有 LLM provider,未來若要新增或移除 provider 必須直接修改程式碼,易產生重複與維護負擔。建議將 provider 設定抽離至外部 JSON/YAML 檔或使用可擴充的資料結構,於程式中載入,以提升模組化與可維護性。",
"is_new": true
},
{
"level": "warning",
"role": "Zara",
"location": "app/config.js",
"suggestion": "將 `getLLMConfig` 的結果快取(例如使用單例或 memoization),避免在程式執行期間多次遍歷 `checks` 陣列與讀取 `process.env`,可大幅降低 I/O 與 CPU 開銷。",
"is_new": true
},
{
"level": "warning",
"role": "Zara",
"location": "app/config.js:12",
"suggestion": "改用映射表(Map)或物件儲存 provider 設定,並以 O(1) 方式查找符合條件的項目,減少每次呼叫時的線性掃描成本。",
"is_new": true
},
{
"level": "warning",
"role": "Rex",
"location": ".gitea/workflows/review.yaml:33-35",
"suggestion": "工作流程目前授予 contents、pullrequests、issues 三項 write 權限過於寬鬆。建議依實際需求僅授予 read 或最小必要的 write 權限,降低被濫用的風險。",
"is_new": true
},
{
"level": "warning",
"role": "Rex",
"location": ".gitea/workflows/review.yaml:33",
"suggestion": "將 OPENAI_API_KEY 參數改為使用正確的 secret 名稱(如 OPENROUTER_API_KEY)時,請確保工作流程檔案中不會同時暴露兩個不同的 secret 名稱,以免因名稱錯誤導致金鑰未傳入或意外洩漏。",
"is_new": true
},
{
"level": "warning",
"role": "Rex",
"location": ".gitea/ai-review/exclusions.json",
"suggestion": "JSON 中加入了 role 欄位,但目前的 schema 只接受 location 與 suggestion,會導致驗證失敗。請移除不必要的 role 欄位或更新 schema,以避免程式在載入時拋出錯誤。",
"is_new": true
},
{
"level": "warning",
"role": "Rex",
"location": "app/config.js:12",
"suggestion": "在判斷 API 金鑰是否有效時,應先檢查 key 是否為非空字串,避免空字串被誤認為有效金鑰而發送請求。可改為 `if (key && key.trim() && baseURL) …`。",
"is_new": true
},
{
"level": "warning",
"role": "Aria",
"location": ".gitea/ai-review/exclusions.json:7",
"suggestion": "檔案中出現兩筆相同的 GITEA_TOKEN 建議移除重複項目,保持唯一性。",
"is_new": true
},
{
"level": "warning",
"role": "Aria",
"location": ".gitea/ai-review/exclusions.json",
"suggestion": "檔案最後缺少換行符號,請在檔案結尾加入一個空白換行,以符合 POSIX 標準。",
"is_new": true
},
{
"level": "warning",
"role": "Aria",
"location": ".gitea/ai-review/findings.json",
"suggestion": "檔案最後缺少換行符號,請在檔案結尾加入一個空白換行。",
"is_new": true
},
{
"level": "warning",
"role": "Aria",
"location": "app/config.js:12-13",
"suggestion": "`checks` 陣列每一行超過 120 個字元,請拆成多行並對齊欄位,以符合常見的行長限制。",
"is_new": true
},
{
"level": "warning",
"role": "Aria",
"location": "app/config.js:13",
"suggestion": "`amazonq` 那一行的空格對齊與其他項目不一致,請統一使用單一個空格分隔欄位或使用對齊工具保持列的垂直對齊。",
"is_new": true
},
{
"level": "warning",
"role": "Aria",
"location": "app/config.test.js",
"suggestion": "檔案最後缺少換行符號,請在檔案結尾加入空白換行。",
"is_new": true
},
{
"level": "warning",
"role": "Aria",
"location": "README.md:28",
"suggestion": "文件中章節編號不連續(例如 `### 2. OpenRouter` 後直接跳到 `### 3. Anthropic Claude`),請重新編號或使用自動編號方式,保持編號連續。",
"is_new": true
},
{
"level": "warning",
"role": "Aria",
"location": "README.md:42",
"suggestion": "標題層級使用不一致,部分章節使用 `### 1.`、`### 2.`,而後面的章節直接跳到 `### 3.`,建議統一使用相同層級的 Markdown 標題,並在每個標題後留一個空行以提升可讀性。",
"is_new": true
},
{
"level": "warning",
"role": "Aria",
"location": "action.yaml:72-99",
"suggestion": "大量移除的輸入欄位留下多行空白與註解,請整理檔案結構,移除不必要的空行與註解,保持檔案整潔。",
"is_new": true
},
{
"level": "info",
"role": "Leo",
"location": "app/findings.js:150",
"suggestion": "在 `filterFalsePositivesWithAI` 中,當 AI 回傳空陣列時拋出錯誤,可能導致上層流程中斷。建議改為回傳原始 `findings` 或提供更具體的錯誤類別,並在文件中說明此行為,以提升錯誤處理的可預測性。",
"is_new": false
},
{
"level": "info",
"role": "Zara",
"location": "app/findings.js",
"suggestion": "在 filterFalsePositivesWithAI 中,若 AI 回傳的陣列非常大,建議在回傳前加入分頁或限制筆數,避免一次性載入過多資料導致記憶體使用量激增。",
"is_new": false
},
{
"level": "info",
"role": "Zara",
"location": "app/config.js",
"suggestion": "對於未設定 API 金鑰的 provider(如 ollama),可提前返回快取的預設設定,避免每次呼叫都進行條件檢查。",
"is_new": false
},
{
"level": "info",
"role": "Rex",
"location": "README.md:28",
"suggestion": "文件中列出的權限說明應與實際 workflow 中的 permissions 保持一致,並提醒使用者僅在必要時授予 write 權限,避免在 CI/CD 環境中過度授權。",
"is_new": false
},
{
"level": "info",
"role": "Rex",
"location": "app/config.js:12",
"suggestion": "在取得 LLM 設定時,若 key 為空字串仍會被視為有效。建議在判斷前先檢查 key 是否為非空字串,以防止意外使用空的 API 金鑰發送請求。",
"is_new": false
},
{
"level": "info",
"role": "Aria",
"location": "app/config.test.js",
"suggestion": "匯入語句過長,建議改寫為多行匯入,例如:\n```js\nimport {\n describe,\n it,\n beforeEach,\n afterEach\n} from 'node:test';\n```",
"is_new": false
},
{
"level": "info",
"role": "Aria",
"location": "app/config.test.js",
"suggestion": "`ENV_KEYS` 陣列過長,建議分行列舉,每行放置一個環境變數,以提升可讀性。",
"is_new": false
},
{
"level": "info",
"role": "Aria",
"location": "app/findings.js",
"suggestion": "錯誤訊息 `AI 回傳空陣列或非陣列` 可簡化為 `AI 回傳的結果不是有效的非空陣列`,讓訊息更清晰。",
"is_new": false
},
{
"level": "info",
"role": "Leo",
"location": "app/config.js:12",
"suggestion": "`checks` 陣列的每一行過長,超過 120 個字元,建議拆成多行並對齊欄位,以符合程式碼可讀性與行長限制的慣例。",
"is_new": true
},
{
"level": "info",
"role": "Leo",
"location": "app/findings.js:151",
"suggestion": "函式內使用 `console.log` 輸出過濾結果,可能在正式環境產生過多日誌。建議改以 logger 並提供可設定的 log level,或在非除錯模式下移除此輸出。",
"is_new": true
},
{
"level": "info",
"role": "Leo",
"location": "app/config.test.js:1",
"suggestion": "匯入語句過長,建議改寫為多行匯入,以提升可讀性,例如:\n```js\nimport {\n describe,\n it,\n beforeEach,\n afterEach\n} from 'node:test';\n```",
"is_new": true
},
{
"level": "info",
"role": "Leo",
"location": "app/config.test.js:9",
"suggestion": "`ENV_KEYS` 陣列過長,建議分行列舉,每行放置一個環境變數,以提升可讀性與維護性。",
"is_new": true
},
{
"level": "info",
"role": "Zara",
"location": "app/findings.js:149",
"suggestion": "在 `filterFalsePositivesWithAI` 中,若 AI 回傳的陣列可能非常大,建議加入分頁或筆數上限(例如一次只處理前 500 筆),避免一次性載入過多資料導致記憶體使用激增。",
"is_new": true
},
{
"level": "info",
"role": "Aria",
"location": "app/config.test.js:1",
"suggestion": "匯入語句過長,建議改寫為多行匯入,例如:\n```js\nimport {\n describe,\n it,\n beforeEach,\n afterEach\n} from 'node:test';\n```",
"is_new": true
},
{
"level": "info",
"role": "Aria",
"location": "app/config.test.js:7",
"suggestion": "`ENV_KEYS` 陣列過長,建議每行放置一個環境變數,分行列舉以提升可讀性。",
"is_new": true
},
{
"level": "info",
"role": "Aria",
"location": ".gitea/workflows/review.yaml:33",
"suggestion": "在 `OPENAI_API_KEY` 後的註解前保留一個空格,以符合常見的 YAML 註解風格:`... ${{ secrets.OPENROUTER_API_KEY }} # OpenRouter 使用 OpenAI 相容介面,以 OPENAI_API_KEY 傳入`。",
"is_new": true
}
]