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

@@ -22,9 +22,13 @@ function resolveSessionEntryForKey(
store: Record<string, SessionEntry> | undefined,
sessionKey: string | undefined,
) {
if (!store || !sessionKey) return {};
if (!store || !sessionKey) {
return {};
}
const direct = store[sessionKey];
if (direct) return { entry: direct, key: sessionKey };
if (direct) {
return { entry: direct, key: sessionKey };
}
return {};
}
@@ -36,7 +40,9 @@ function resolveAbortTarget(params: {
}) {
const targetSessionKey = params.ctx.CommandTargetSessionKey?.trim() || params.sessionKey;
const { entry, key } = resolveSessionEntryForKey(params.sessionStore, targetSessionKey);
if (entry && key) return { entry, key, sessionId: entry.sessionId };
if (entry && key) {
return { entry, key, sessionId: entry.sessionId };
}
if (params.sessionEntry && params.sessionKey) {
return {
entry: params.sessionEntry,
@@ -48,9 +54,13 @@ function resolveAbortTarget(params: {
}
export const handleActivationCommand: CommandHandler = async (params, allowTextCommands) => {
if (!allowTextCommands) return null;
if (!allowTextCommands) {
return null;
}
const activationCommand = parseActivationCommand(params.command.commandBodyNormalized);
if (!activationCommand.hasCommand) return null;
if (!activationCommand.hasCommand) {
return null;
}
if (!params.isGroup) {
return {
shouldContinue: false,
@@ -89,9 +99,13 @@ export const handleActivationCommand: CommandHandler = async (params, allowTextC
};
export const handleSendPolicyCommand: CommandHandler = async (params, allowTextCommands) => {
if (!allowTextCommands) return null;
if (!allowTextCommands) {
return null;
}
const sendPolicyCommand = parseSendPolicyCommand(params.command.commandBodyNormalized);
if (!sendPolicyCommand.hasCommand) return null;
if (!sendPolicyCommand.hasCommand) {
return null;
}
if (!params.command.isAuthorizedSender) {
logVerbose(
`Ignoring /send from unauthorized sender: ${params.command.senderId || "<unknown>"}`,
@@ -131,9 +145,13 @@ export const handleSendPolicyCommand: CommandHandler = async (params, allowTextC
};
export const handleUsageCommand: CommandHandler = async (params, allowTextCommands) => {
if (!allowTextCommands) return null;
if (!allowTextCommands) {
return null;
}
const normalized = params.command.commandBodyNormalized;
if (normalized !== "/usage" && !normalized.startsWith("/usage ")) return null;
if (normalized !== "/usage" && !normalized.startsWith("/usage ")) {
return null;
}
if (!params.command.isAuthorizedSender) {
logVerbose(
`Ignoring /usage from unauthorized sender: ${params.command.senderId || "<unknown>"}`,
@@ -195,8 +213,11 @@ export const handleUsageCommand: CommandHandler = async (params, allowTextComman
const next = requested ?? (current === "off" ? "tokens" : current === "tokens" ? "full" : "off");
if (params.sessionEntry && params.sessionStore && params.sessionKey) {
if (next === "off") delete params.sessionEntry.responseUsage;
else params.sessionEntry.responseUsage = next;
if (next === "off") {
delete params.sessionEntry.responseUsage;
} else {
params.sessionEntry.responseUsage = next;
}
params.sessionEntry.updatedAt = Date.now();
params.sessionStore[params.sessionKey] = params.sessionEntry;
if (params.storePath) {
@@ -215,8 +236,12 @@ export const handleUsageCommand: CommandHandler = async (params, allowTextComman
};
export const handleRestartCommand: CommandHandler = async (params, allowTextCommands) => {
if (!allowTextCommands) return null;
if (params.command.commandBodyNormalized !== "/restart") return null;
if (!allowTextCommands) {
return null;
}
if (params.command.commandBodyNormalized !== "/restart") {
return null;
}
if (!params.command.isAuthorizedSender) {
logVerbose(
`Ignoring /restart from unauthorized sender: ${params.command.senderId || "<unknown>"}`,
@@ -260,8 +285,12 @@ export const handleRestartCommand: CommandHandler = async (params, allowTextComm
};
export const handleStopCommand: CommandHandler = async (params, allowTextCommands) => {
if (!allowTextCommands) return null;
if (params.command.commandBodyNormalized !== "/stop") return null;
if (!allowTextCommands) {
return null;
}
if (params.command.commandBodyNormalized !== "/stop") {
return null;
}
if (!params.command.isAuthorizedSender) {
logVerbose(
`Ignoring /stop from unauthorized sender: ${params.command.senderId || "<unknown>"}`,
@@ -319,8 +348,12 @@ export const handleStopCommand: CommandHandler = async (params, allowTextCommand
};
export const handleAbortTrigger: CommandHandler = async (params, allowTextCommands) => {
if (!allowTextCommands) return null;
if (!isAbortTrigger(params.command.rawBodyNormalized)) return null;
if (!allowTextCommands) {
return null;
}
if (!isAbortTrigger(params.command.rawBodyNormalized)) {
return null;
}
const abortTarget = resolveAbortTarget({
ctx: params.ctx,
sessionKey: params.sessionKey,