mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 02:42:43 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -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" ||
|
||||
|
||||
Reference in New Issue
Block a user