From fae60ed0e78a51ce46b6a4d617f9432f0f04ab97 Mon Sep 17 00:00:00 2001 From: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 22:53:57 -0400 Subject: [PATCH] chore(coverage): v8-ignore the bundle-unreachable fallback arms in run.ts, command.ts and config.ts The e2e coverage run reports three fallback arms at zero hits that no input to dist/index.js can reach: - run.ts: the String(error) arm of run()'s catch. Every handler folds its rejections into an Error (runEventHandlers, normalizeError, the jobs .catch), and the only throw that reaches this catch from the bundle is a built-in TypeError. - command.ts: getLineArgs's ?? '' fallback. Its callers (/milestone, /retitle) run only after hasCommand matched the same pattern. - config.ts: the non-Error arm in normalizeSweep; parseDuration throws only Error. Mark them with /* v8 ignore next */, the form config.ts already uses for its test-only hooks. The hint sits on the alternate of the ?: so the Error arms stay measured; for the ?? it has to sit on the statement because the coverage mapper does not honour a hint on one operand of a logical expression. No behaviour change; the unit tests that drive the arms stay. dist/ repacked. Refs #523 Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- dist/index.js | 10 ++++++++-- src/run.ts | 4 +++- src/utils/command.ts | 3 +++ src/utils/config.ts | 3 ++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6b20c354..a9cc7ee0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -41242,7 +41242,8 @@ function normalizeSweep(source, raw) { ms = parseDuration(raw.lookback, 'sweep.lookback'); } catch (e) { - throw new Error(`${source}: ${e instanceof Error ? e.message : e}`); + // parseDuration throws only Error + throw new Error(`${source}: ${e instanceof Error ? e.message : /* v8 ignore next -- non-Error arm unreachable from dist/index.js; configSweep.test.ts drives it */ e}`); } if (ms <= 0) { throw new Error(`${source}: sweep.lookback must be longer than 0`); @@ -42622,6 +42623,9 @@ function hasCommand(command, body) { * @param body - the full body of the comment */ function getLineArgs(command, body) { + // both callers (/milestone, /retitle) run only after hasCommand matched the same pattern, so at(-1) is a string from the bundle; + // the hint sits on the statement because a hint on one operand of a ?? expression is not honoured + /* v8 ignore next -- absent-command fallback unreachable from dist/index.js; command.test.ts drives it */ return findCommandArgs(command, body).at(-1) ?? ''; } /** @@ -46905,7 +46909,9 @@ async function run() { await handler(context); } catch (error) { - setFailed(error instanceof Error ? error.message : String(error)); + // every handler folds its rejections into an Error (runEventHandlers, normalizeError, the jobs .catch), + // and the only throw that reaches this catch from the bundle is a built-in TypeError + setFailed(error instanceof Error ? error.message : /* v8 ignore next -- non-Error arm unreachable from dist/index.js; run.test.ts drives it */ String(error)); } } diff --git a/src/run.ts b/src/run.ts index 3409d0e8..f0cb100a 100644 --- a/src/run.ts +++ b/src/run.ts @@ -37,6 +37,8 @@ export async function run(): Promise { await handler(context) } catch (error) { - core.setFailed(error instanceof Error ? error.message : String(error)) + // every handler folds its rejections into an Error (runEventHandlers, normalizeError, the jobs .catch), + // and the only throw that reaches this catch from the bundle is a built-in TypeError + core.setFailed(error instanceof Error ? error.message : /* v8 ignore next -- non-Error arm unreachable from dist/index.js; run.test.ts drives it */ String(error)) } } diff --git a/src/utils/command.ts b/src/utils/command.ts index d3953163..b406f564 100644 --- a/src/utils/command.ts +++ b/src/utils/command.ts @@ -20,6 +20,9 @@ export function hasCommand(command: string, body: string): boolean { * @param body - the full body of the comment */ export function getLineArgs(command: string, body: string): string { + // both callers (/milestone, /retitle) run only after hasCommand matched the same pattern, so at(-1) is a string from the bundle; + // the hint sits on the statement because a hint on one operand of a ?? expression is not honoured + /* v8 ignore next -- absent-command fallback unreachable from dist/index.js; command.test.ts drives it */ return findCommandArgs(command, body).at(-1) ?? '' } diff --git a/src/utils/config.ts b/src/utils/config.ts index c71efa2f..057b4a65 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -654,7 +654,8 @@ function normalizeSweep(source: string, raw: unknown): SweepConfig { ms = parseDuration(raw.lookback, 'sweep.lookback') } catch (e) { - throw new Error(`${source}: ${e instanceof Error ? e.message : e}`) + // parseDuration throws only Error + throw new Error(`${source}: ${e instanceof Error ? e.message : /* v8 ignore next -- non-Error arm unreachable from dist/index.js; configSweep.test.ts drives it */ e}`) } if (ms <= 0) { throw new Error(`${source}: sweep.lookback must be longer than 0`)