From ec7e526b2a329c206923f98a3df5f2c86d79340b Mon Sep 17 00:00:00 2001 From: David Cramer Date: Sun, 22 Feb 2026 11:03:52 -0800 Subject: [PATCH] ref: Simplify repetitive column width calculations in logs Warden finding code-simplifier-36a025b2 Severity: medium Co-Authored-By: Warden --- src/cli/commands/logs.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/cli/commands/logs.ts b/src/cli/commands/logs.ts index 251f1fe4..1f7d6596 100644 --- a/src/cli/commands/logs.ts +++ b/src/cli/commands/logs.ts @@ -262,17 +262,12 @@ export async function runLogsList(options: CLIOptions, reporter: Reporter): Prom model: 'MODEL', skills: 'SKILLS', }; - const widths = { - runId: Math.max(headers.runId.length, ...rows.map((r) => visualWidth(r.runId))), - date: Math.max(headers.date.length, ...rows.map((r) => visualWidth(r.date))), - files: Math.max(headers.files.length, ...rows.map((r) => visualWidth(r.files))), - findings: Math.max(headers.findings.length, ...rows.map((r) => visualWidth(r.findings))), - time: Math.max(headers.time.length, ...rows.map((r) => visualWidth(r.time))), - cost: Math.max(headers.cost.length, ...rows.map((r) => visualWidth(r.cost))), - sha: Math.max(headers.sha.length, ...rows.map((r) => visualWidth(r.sha))), - model: Math.max(headers.model.length, ...rows.map((r) => visualWidth(r.model))), - skills: Math.max(headers.skills.length, ...rows.map((r) => visualWidth(r.skills))), - }; + const widths = Object.fromEntries( + Object.keys(headers).map((key) => { + const col = key as keyof Row; + return [col, Math.max(headers[col].length, ...rows.map((r) => visualWidth(r[col])))]; + }), + ) as Record; // Header row const headerLine =