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

@@ -108,7 +108,9 @@ export async function modelsStatusCommand(
const aliases = Object.entries(cfg.agents?.defaults?.models ?? {}).reduce<Record<string, string>>(
(acc, [key, entry]) => {
const alias = entry?.alias?.trim();
if (alias) acc[alias] = key;
if (alias) {
acc[alias] = key;
}
return acc;
},
{},
@@ -132,11 +134,15 @@ export async function modelsStatusCommand(
const providersInUse = new Set<string>();
for (const raw of [defaultLabel, ...fallbacks, imageModel, ...imageFallbacks, ...allowed]) {
const parsed = parseModelRef(String(raw ?? ""), DEFAULT_PROVIDER);
if (parsed?.provider) providersFromModels.add(parsed.provider);
if (parsed?.provider) {
providersFromModels.add(parsed.provider);
}
}
for (const raw of [defaultLabel, ...fallbacks, imageModel, ...imageFallbacks]) {
const parsed = parseModelRef(String(raw ?? ""), DEFAULT_PROVIDER);
if (parsed?.provider) providersInUse.add(parsed.provider);
if (parsed?.provider) {
providersInUse.add(parsed.provider);
}
}
const providersFromEnv = new Set<string>();
@@ -157,7 +163,9 @@ export async function modelsStatusCommand(
"synthetic",
];
for (const provider of envProbeProviders) {
if (resolveEnvApiKey(provider)) providersFromEnv.add(provider);
if (resolveEnvApiKey(provider)) {
providersFromEnv.add(provider);
}
}
const providers = Array.from(
@@ -188,7 +196,9 @@ export async function modelsStatusCommand(
.toSorted((a, b) => a.localeCompare(b));
const probeProfileIds = (() => {
if (!opts.probeProfile) return [];
if (!opts.probeProfile) {
return [];
}
const raw = Array.isArray(opts.probeProfile) ? opts.probeProfile : [opts.probeProfile];
return raw
.flatMap((value) => String(value ?? "").split(","))
@@ -283,7 +293,9 @@ export async function modelsStatusCommand(
}> = [];
for (const profileId of Object.keys(store.usageStats ?? {})) {
const unusableUntil = resolveProfileUnusableUntilForDisplay(store, profileId);
if (!unusableUntil || now >= unusableUntil) continue;
if (!unusableUntil || now >= unusableUntil) {
continue;
}
const stats = store.usageStats?.[profileId];
const kind =
typeof stats?.disabledUntil === "number" && now < stats.disabledUntil
@@ -306,8 +318,12 @@ export async function modelsStatusCommand(
oauthProfiles.some((profile) => ["expired", "missing"].includes(profile.status)) ||
missingProvidersInUse.length > 0;
const hasExpiring = oauthProfiles.some((profile) => profile.status === "expiring");
if (hasExpiredOrMissing) return 1;
if (hasExpiring) return 2;
if (hasExpiredOrMissing) {
return 1;
}
if (hasExpiring) {
return 2;
}
return 0;
})();
@@ -355,13 +371,17 @@ export async function modelsStatusCommand(
2,
),
);
if (opts.check) runtime.exit(checkStatus);
if (opts.check) {
runtime.exit(checkStatus);
}
return;
}
if (opts.plain) {
runtime.log(resolvedLabel);
if (opts.check) runtime.exit(checkStatus);
if (opts.check) {
runtime.exit(checkStatus);
}
return;
}
@@ -564,18 +584,29 @@ export async function modelsStatusCommand(
}
const formatStatus = (status: string) => {
if (status === "ok") return colorize(rich, theme.success, "ok");
if (status === "static") return colorize(rich, theme.muted, "static");
if (status === "expiring") return colorize(rich, theme.warn, "expiring");
if (status === "missing") return colorize(rich, theme.warn, "unknown");
if (status === "ok") {
return colorize(rich, theme.success, "ok");
}
if (status === "static") {
return colorize(rich, theme.muted, "static");
}
if (status === "expiring") {
return colorize(rich, theme.warn, "expiring");
}
if (status === "missing") {
return colorize(rich, theme.warn, "unknown");
}
return colorize(rich, theme.error, "expired");
};
const profilesByProvider = new Map<string, typeof oauthProfiles>();
for (const profile of oauthProfiles) {
const current = profilesByProvider.get(profile.provider);
if (current) current.push(profile);
else profilesByProvider.set(profile.provider, [profile]);
if (current) {
current.push(profile);
} else {
profilesByProvider.set(profile.provider, [profile]);
}
}
for (const [provider, profiles] of profilesByProvider) {
@@ -607,11 +638,21 @@ export async function modelsStatusCommand(
const tableWidth = Math.max(60, (process.stdout.columns ?? 120) - 1);
const sorted = sortProbeResults(probeSummary.results);
const statusColor = (status: string) => {
if (status === "ok") return theme.success;
if (status === "rate_limit") return theme.warn;
if (status === "timeout" || status === "billing") return theme.warn;
if (status === "auth" || status === "format") return theme.error;
if (status === "no_model") return theme.muted;
if (status === "ok") {
return theme.success;
}
if (status === "rate_limit") {
return theme.warn;
}
if (status === "timeout" || status === "billing") {
return theme.warn;
}
if (status === "auth" || status === "format") {
return theme.error;
}
if (status === "no_model") {
return theme.muted;
}
return theme.muted;
};
const rows = sorted.map((result) => {
@@ -644,5 +685,7 @@ export async function modelsStatusCommand(
}
}
if (opts.check) runtime.exit(checkStatus);
if (opts.check) {
runtime.exit(checkStatus);
}
}