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

@@ -13,7 +13,9 @@ function isProfileForProvider(params: {
store: ReturnType<typeof ensureAuthProfileStore>;
}): boolean {
const entry = params.store.profiles[params.profileId];
if (!entry?.provider) return false;
if (!entry?.provider) {
return false;
}
return normalizeProviderId(entry.provider) === normalizeProviderId(params.provider);
}
@@ -56,7 +58,9 @@ export async function resolveSessionAuthProfileOverride(params: {
storePath,
isNewSession,
} = params;
if (!sessionEntry || !sessionStore || !sessionKey) return sessionEntry?.authProfileOverride;
if (!sessionEntry || !sessionStore || !sessionKey) {
return sessionEntry?.authProfileOverride;
}
const store = ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false });
const order = resolveAuthProfileOrder({ cfg, store, provider });
@@ -77,16 +81,22 @@ export async function resolveSessionAuthProfileOverride(params: {
current = undefined;
}
if (order.length === 0) return undefined;
if (order.length === 0) {
return undefined;
}
const pickFirstAvailable = () =>
order.find((profileId) => !isProfileInCooldown(store, profileId)) ?? order[0];
const pickNextAvailable = (active: string) => {
const startIndex = order.indexOf(active);
if (startIndex < 0) return pickFirstAvailable();
if (startIndex < 0) {
return pickFirstAvailable();
}
for (let offset = 1; offset <= order.length; offset += 1) {
const candidate = order[(startIndex + offset) % order.length];
if (!isProfileInCooldown(store, candidate)) return candidate;
if (!isProfileInCooldown(store, candidate)) {
return candidate;
}
}
return order[startIndex] ?? order[0];
};
@@ -117,7 +127,9 @@ export async function resolveSessionAuthProfileOverride(params: {
next = pickFirstAvailable();
}
if (!next) return current;
if (!next) {
return current;
}
const shouldPersist =
next !== sessionEntry.authProfileOverride ||
sessionEntry.authProfileOverrideSource !== "auto" ||