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

@@ -16,12 +16,18 @@ function resolveAccountGroups(
cfg: OpenClawConfig,
accountId?: string | null,
): { groups?: TelegramGroups } {
if (!accountId) return {};
if (!accountId) {
return {};
}
const normalized = normalizeAccountId(accountId);
const accounts = cfg.channels?.telegram?.accounts;
if (!accounts || typeof accounts !== "object") return {};
if (!accounts || typeof accounts !== "object") {
return {};
}
const exact = accounts[normalized];
if (exact?.groups) return { groups: exact.groups };
if (exact?.groups) {
return { groups: exact.groups };
}
const matchKey = Object.keys(accounts).find(
(key) => key.toLowerCase() === normalized.toLowerCase(),
);
@@ -33,10 +39,18 @@ export function migrateTelegramGroupsInPlace(
oldChatId: string,
newChatId: string,
): { migrated: boolean; skippedExisting: boolean } {
if (!groups) return { migrated: false, skippedExisting: false };
if (oldChatId === newChatId) return { migrated: false, skippedExisting: false };
if (!Object.hasOwn(groups, oldChatId)) return { migrated: false, skippedExisting: false };
if (Object.hasOwn(groups, newChatId)) return { migrated: false, skippedExisting: true };
if (!groups) {
return { migrated: false, skippedExisting: false };
}
if (oldChatId === newChatId) {
return { migrated: false, skippedExisting: false };
}
if (!Object.hasOwn(groups, oldChatId)) {
return { migrated: false, skippedExisting: false };
}
if (Object.hasOwn(groups, newChatId)) {
return { migrated: false, skippedExisting: true };
}
groups[newChatId] = groups[oldChatId];
delete groups[oldChatId];
return { migrated: true, skippedExisting: false };
@@ -59,7 +73,9 @@ export function migrateTelegramGroupConfig(params: {
migrated = true;
scopes.push("account");
}
if (result.skippedExisting) skippedExisting = true;
if (result.skippedExisting) {
skippedExisting = true;
}
}
const globalGroups = params.cfg.channels?.telegram?.groups;
@@ -69,7 +85,9 @@ export function migrateTelegramGroupConfig(params: {
migrated = true;
scopes.push("global");
}
if (result.skippedExisting) skippedExisting = true;
if (result.skippedExisting) {
skippedExisting = true;
}
}
return { migrated, skippedExisting, scopes };