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 resolveAccountChannels(
cfg: OpenClawConfig,
accountId?: string | null,
): { channels?: SlackChannels } {
if (!accountId) return {};
if (!accountId) {
return {};
}
const normalized = normalizeAccountId(accountId);
const accounts = cfg.channels?.slack?.accounts;
if (!accounts || typeof accounts !== "object") return {};
if (!accounts || typeof accounts !== "object") {
return {};
}
const exact = accounts[normalized];
if (exact?.channels) return { channels: exact.channels };
if (exact?.channels) {
return { channels: exact.channels };
}
const matchKey = Object.keys(accounts).find(
(key) => key.toLowerCase() === normalized.toLowerCase(),
);
@@ -33,10 +39,18 @@ export function migrateSlackChannelsInPlace(
oldChannelId: string,
newChannelId: string,
): { migrated: boolean; skippedExisting: boolean } {
if (!channels) return { migrated: false, skippedExisting: false };
if (oldChannelId === newChannelId) return { migrated: false, skippedExisting: false };
if (!Object.hasOwn(channels, oldChannelId)) return { migrated: false, skippedExisting: false };
if (Object.hasOwn(channels, newChannelId)) return { migrated: false, skippedExisting: true };
if (!channels) {
return { migrated: false, skippedExisting: false };
}
if (oldChannelId === newChannelId) {
return { migrated: false, skippedExisting: false };
}
if (!Object.hasOwn(channels, oldChannelId)) {
return { migrated: false, skippedExisting: false };
}
if (Object.hasOwn(channels, newChannelId)) {
return { migrated: false, skippedExisting: true };
}
channels[newChannelId] = channels[oldChannelId];
delete channels[oldChannelId];
return { migrated: true, skippedExisting: false };
@@ -63,7 +77,9 @@ export function migrateSlackChannelConfig(params: {
migrated = true;
scopes.push("account");
}
if (result.skippedExisting) skippedExisting = true;
if (result.skippedExisting) {
skippedExisting = true;
}
}
const globalChannels = params.cfg.channels?.slack?.channels;
@@ -77,7 +93,9 @@ export function migrateSlackChannelConfig(params: {
migrated = true;
scopes.push("global");
}
if (result.skippedExisting) skippedExisting = true;
if (result.skippedExisting) {
skippedExisting = true;
}
}
return { migrated, skippedExisting, scopes };