From 0221a447f39af0c13ef906bb9087cf7cd833a7c3 Mon Sep 17 00:00:00 2001 From: DMarinhoCodacy Date: Fri, 4 Sep 2026 19:18:31 +0100 Subject: [PATCH] Fix output handling --- src/engineImpl.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/engineImpl.ts b/src/engineImpl.ts index f85e33e..9b156da 100644 --- a/src/engineImpl.ts +++ b/src/engineImpl.ts @@ -153,10 +153,11 @@ function runOxlint( try { const parsed = JSON.parse((result.stdout ?? "").trim()) as OxlintOutput; return { diagnostics: parsed.diagnostics ?? [] }; - } catch { - // Failed to parse: this is a real error - const errorMsg = result.stderr || `Exit code ${result.status}`; - return { diagnostics: [], error: `Failed to parse oxlint output: ${errorMsg.slice(0, 500)}` }; + } catch (parseErr) { + // Failed to parse JSON output + const stderr = result.stderr?.slice(0, 200) || ""; + const reason = stderr || `oxlint exited with code ${result.status}`; + return { diagnostics: [], error: `Failed to parse oxlint output: ${reason}` }; } } @@ -204,6 +205,11 @@ export async function engineImpl(rc: CodacyRc | undefined): Promise { } for (const diag of diagnostics) { + if (!diag.code) { + process.stderr.write(`[codacy-oxlint] Warning: Skipping issue in ${diag.filename}:${getLine(diag)} - missing rule code\n`); + continue; + } + const issue: CodacyIssue = { filename: diag.filename.startsWith(SOURCE_DIR) ? diag.filename.slice(SOURCE_DIR.length + 1)