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

@@ -17,7 +17,9 @@ export function limitHistoryTurns(
messages: AgentMessage[],
limit: number | undefined,
): AgentMessage[] {
if (!limit || limit <= 0 || messages.length === 0) return messages;
if (!limit || limit <= 0 || messages.length === 0) {
return messages;
}
let userCount = 0;
let lastUserIndex = messages.length;
@@ -42,18 +44,24 @@ export function getDmHistoryLimitFromSessionKey(
sessionKey: string | undefined,
config: OpenClawConfig | undefined,
): number | undefined {
if (!sessionKey || !config) return undefined;
if (!sessionKey || !config) {
return undefined;
}
const parts = sessionKey.split(":").filter(Boolean);
const providerParts = parts.length >= 3 && parts[0] === "agent" ? parts.slice(2) : parts;
const provider = providerParts[0]?.toLowerCase();
if (!provider) return undefined;
if (!provider) {
return undefined;
}
const kind = providerParts[1]?.toLowerCase();
const userIdRaw = providerParts.slice(2).join(":");
const userId = stripThreadSuffix(userIdRaw);
if (kind !== "dm") return undefined;
if (kind !== "dm") {
return undefined;
}
const getLimit = (
providerConfig:
@@ -63,7 +71,9 @@ export function getDmHistoryLimitFromSessionKey(
}
| undefined,
): number | undefined => {
if (!providerConfig) return undefined;
if (!providerConfig) {
return undefined;
}
if (userId && providerConfig.dms?.[userId]?.historyLimit !== undefined) {
return providerConfig.dms[userId].historyLimit;
}
@@ -75,9 +85,13 @@ export function getDmHistoryLimitFromSessionKey(
providerId: string,
): { dmHistoryLimit?: number; dms?: Record<string, { historyLimit?: number }> } | undefined => {
const channels = cfg?.channels;
if (!channels || typeof channels !== "object") return undefined;
if (!channels || typeof channels !== "object") {
return undefined;
}
const entry = (channels as Record<string, unknown>)[providerId];
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return undefined;
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
return undefined;
}
return entry as { dmHistoryLimit?: number; dms?: Record<string, { historyLimit?: number }> };
};