chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -31,9 +31,13 @@ import {
import { addGatewayRunCommand } from "./run.js";
function styleHealthChannelLine(line: string, rich: boolean): string {
if (!rich) return line;
if (!rich) {
return line;
}
const colon = line.indexOf(":");
if (colon === -1) return line;
if (colon === -1) {
return line;
}
const label = line.slice(0, colon + 1);
const detail = line.slice(colon + 1).trimStart();
@@ -42,13 +46,27 @@ function styleHealthChannelLine(line: string, rich: boolean): string {
const applyPrefix = (prefix: string, color: (value: string) => string) =>
`${label} ${color(detail.slice(0, prefix.length))}${detail.slice(prefix.length)}`;
if (normalized.startsWith("failed")) return applyPrefix("failed", theme.error);
if (normalized.startsWith("ok")) return applyPrefix("ok", theme.success);
if (normalized.startsWith("linked")) return applyPrefix("linked", theme.success);
if (normalized.startsWith("configured")) return applyPrefix("configured", theme.success);
if (normalized.startsWith("not linked")) return applyPrefix("not linked", theme.warn);
if (normalized.startsWith("not configured")) return applyPrefix("not configured", theme.muted);
if (normalized.startsWith("unknown")) return applyPrefix("unknown", theme.warn);
if (normalized.startsWith("failed")) {
return applyPrefix("failed", theme.error);
}
if (normalized.startsWith("ok")) {
return applyPrefix("ok", theme.success);
}
if (normalized.startsWith("linked")) {
return applyPrefix("linked", theme.success);
}
if (normalized.startsWith("configured")) {
return applyPrefix("configured", theme.success);
}
if (normalized.startsWith("not linked")) {
return applyPrefix("not linked", theme.warn);
}
if (normalized.startsWith("not configured")) {
return applyPrefix("not configured", theme.muted);
}
if (normalized.startsWith("unknown")) {
return applyPrefix("unknown", theme.warn);
}
return line;
}
@@ -62,10 +80,14 @@ function runGatewayCommand(action: () => Promise<void>, label?: string) {
}
function parseDaysOption(raw: unknown, fallback = 30): number {
if (typeof raw === "number" && Number.isFinite(raw)) return Math.max(1, Math.floor(raw));
if (typeof raw === "number" && Number.isFinite(raw)) {
return Math.max(1, Math.floor(raw));
}
if (typeof raw === "string" && raw.trim() !== "") {
const parsed = Number(raw);
if (Number.isFinite(parsed)) return Math.max(1, Math.floor(parsed));
if (Number.isFinite(parsed)) {
return Math.max(1, Math.floor(parsed));
}
}
return fallback;
}
@@ -324,7 +346,9 @@ export function registerGatewayCli(program: Command) {
`Found ${deduped.length} gateway(s) · domains: ${domains.join(", ")}`,
),
);
if (deduped.length === 0) return;
if (deduped.length === 0) {
return;
}
for (const beacon of deduped) {
for (const line of renderBeaconLines(beacon, rich)) {