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

@@ -19,26 +19,36 @@ function resolveProviderFromContext(ctx: MsgContext, cfg: OpenClawConfig): Chann
normalizeAnyChannelId(ctx.Provider) ??
normalizeAnyChannelId(ctx.Surface) ??
normalizeAnyChannelId(ctx.OriginatingChannel);
if (direct) return direct;
if (direct) {
return direct;
}
const candidates = [ctx.From, ctx.To]
.filter((value): value is string => Boolean(value?.trim()))
.flatMap((value) => value.split(":").map((part) => part.trim()));
for (const candidate of candidates) {
const normalized = normalizeAnyChannelId(candidate);
if (normalized) return normalized;
if (normalized) {
return normalized;
}
}
const configured = listChannelDocks()
.map((dock) => {
if (!dock.config?.resolveAllowFrom) return null;
if (!dock.config?.resolveAllowFrom) {
return null;
}
const allowFrom = dock.config.resolveAllowFrom({
cfg,
accountId: ctx.AccountId,
});
if (!Array.isArray(allowFrom) || allowFrom.length === 0) return null;
if (!Array.isArray(allowFrom) || allowFrom.length === 0) {
return null;
}
return dock.id;
})
.filter((value): value is ChannelId => Boolean(value));
if (configured.length === 1) return configured[0];
if (configured.length === 1) {
return configured[0];
}
return undefined;
}
@@ -49,7 +59,9 @@ function formatAllowFromList(params: {
allowFrom: Array<string | number>;
}): string[] {
const { dock, cfg, accountId, allowFrom } = params;
if (!allowFrom || allowFrom.length === 0) return [];
if (!allowFrom || allowFrom.length === 0) {
return [];
}
if (dock?.config?.formatAllowFrom) {
return dock.config.formatAllowFrom({ cfg, accountId, allowFrom });
}
@@ -84,7 +96,9 @@ function resolveSenderCandidates(params: {
const candidates: string[] = [];
const pushCandidate = (value?: string | null) => {
const trimmed = (value ?? "").trim();
if (!trimmed) return;
if (!trimmed) {
return;
}
candidates.push(trimmed);
};
if (params.providerId === "whatsapp") {
@@ -100,7 +114,9 @@ function resolveSenderCandidates(params: {
for (const sender of candidates) {
const entries = normalizeAllowFromEntry({ dock, cfg, accountId, value: sender });
for (const entry of entries) {
if (!normalized.includes(entry)) normalized.push(entry);
if (!normalized.includes(entry)) {
normalized.push(entry);
}
}
}
return normalized;
@@ -136,7 +152,9 @@ export function resolveCommandAuthorization(params: {
accountId: ctx.AccountId,
value: to,
});
if (normalizedTo.length > 0) ownerCandidates.push(...normalizedTo);
if (normalizedTo.length > 0) {
ownerCandidates.push(...normalizedTo);
}
}
const ownerList = Array.from(new Set(ownerCandidates));