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

@@ -28,14 +28,18 @@ export async function maybeRepairAnthropicOAuthProfileId(
provider: "anthropic",
legacyProfileId: "anthropic:default",
});
if (!repair.migrated || repair.changes.length === 0) return cfg;
if (!repair.migrated || repair.changes.length === 0) {
return cfg;
}
note(repair.changes.map((c) => `- ${c}`).join("\n"), "Auth profiles");
const apply = await prompter.confirm({
message: "Update Anthropic OAuth profile id in config now?",
initialValue: true,
});
if (!apply) return cfg;
if (!apply) {
return cfg;
}
return repair.config;
}
@@ -43,13 +47,19 @@ function pruneAuthOrder(
order: Record<string, string[]> | undefined,
profileIds: Set<string>,
): { next: Record<string, string[]> | undefined; changed: boolean } {
if (!order) return { next: order, changed: false };
if (!order) {
return { next: order, changed: false };
}
let changed = false;
const next: Record<string, string[]> = {};
for (const [provider, list] of Object.entries(order)) {
const filtered = list.filter((id) => !profileIds.has(id));
if (filtered.length !== list.length) changed = true;
if (filtered.length > 0) next[provider] = filtered;
if (filtered.length !== list.length) {
changed = true;
}
if (filtered.length > 0) {
next[provider] = filtered;
}
}
return { next: Object.keys(next).length > 0 ? next : undefined, changed };
}
@@ -73,9 +83,13 @@ function pruneAuthProfiles(
}
const prunedOrder = pruneAuthOrder(order, profileIds);
if (prunedOrder.changed) changed = true;
if (prunedOrder.changed) {
changed = true;
}
if (!changed) return { next: cfg, changed: false };
if (!changed) {
return { next: cfg, changed: false };
}
const nextAuth =
nextProfiles || prunedOrder.next
@@ -108,7 +122,9 @@ export async function maybeRemoveDeprecatedCliAuthProfiles(
deprecated.add(CODEX_CLI_PROFILE_ID);
}
if (deprecated.size === 0) return cfg;
if (deprecated.size === 0) {
return cfg;
}
const lines = ["Deprecated external CLI auth profiles detected (no longer supported):"];
if (deprecated.has(CLAUDE_CLI_PROFILE_ID)) {
@@ -129,7 +145,9 @@ export async function maybeRemoveDeprecatedCliAuthProfiles(
message: "Remove deprecated CLI auth profiles now?",
initialValue: true,
});
if (!shouldRemove) return cfg;
if (!shouldRemove) {
return cfg;
}
await updateAuthProfileStoreWithLock({
updater: (nextStore) => {
@@ -222,7 +240,9 @@ export async function noteAuthProfileHealth(params: {
const out: string[] = [];
for (const profileId of Object.keys(store.usageStats ?? {})) {
const until = resolveProfileUnusableUntilForDisplay(store, profileId);
if (!until || now >= until) continue;
if (!until || now >= until) {
continue;
}
const stats = store.usageStats?.[profileId];
const remaining = formatRemainingShort(until - now);
const kind =
@@ -257,7 +277,9 @@ export async function noteAuthProfileHealth(params: {
);
let issues = findIssues();
if (issues.length === 0) return;
if (issues.length === 0) {
return;
}
const shouldRefresh = await params.prompter.confirmRepair({
message: "Refresh expiring OAuth tokens now? (static tokens need re-auth)",