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,9 +17,13 @@ export function listChannelSupportedActions(params: {
cfg?: OpenClawConfig;
channel?: string;
}): ChannelMessageActionName[] {
if (!params.channel) return [];
if (!params.channel) {
return [];
}
const plugin = getChannelPlugin(params.channel as Parameters<typeof getChannelPlugin>[0]);
if (!plugin?.actions?.listActions) return [];
if (!plugin?.actions?.listActions) {
return [];
}
const cfg = params.cfg ?? ({} as OpenClawConfig);
return runPluginListActions(plugin, cfg);
}
@@ -32,7 +36,9 @@ export function listAllChannelSupportedActions(params: {
}): ChannelMessageActionName[] {
const actions = new Set<ChannelMessageActionName>();
for (const plugin of listChannelPlugins()) {
if (!plugin.actions?.listActions) continue;
if (!plugin.actions?.listActions) {
continue;
}
const cfg = params.cfg ?? ({} as OpenClawConfig);
const channelActions = runPluginListActions(plugin, cfg);
for (const action of channelActions) {
@@ -47,9 +53,13 @@ export function listChannelAgentTools(params: { cfg?: OpenClawConfig }): Channel
const tools: ChannelAgentTool[] = [];
for (const plugin of listChannelPlugins()) {
const entry = plugin.agentTools;
if (!entry) continue;
if (!entry) {
continue;
}
const resolved = typeof entry === "function" ? entry(params) : entry;
if (Array.isArray(resolved)) tools.push(...resolved);
if (Array.isArray(resolved)) {
tools.push(...resolved);
}
}
return tools;
}
@@ -60,10 +70,14 @@ export function resolveChannelMessageToolHints(params: {
accountId?: string | null;
}): string[] {
const channelId = normalizeAnyChannelId(params.channel);
if (!channelId) return [];
if (!channelId) {
return [];
}
const dock = getChannelDock(channelId);
const resolve = dock?.agentPrompt?.messageToolHints;
if (!resolve) return [];
if (!resolve) {
return [];
}
const cfg = params.cfg ?? ({} as OpenClawConfig);
return (resolve({ cfg, accountId: params.accountId }) ?? [])
.map((entry) => entry.trim())
@@ -76,7 +90,9 @@ function runPluginListActions(
plugin: ChannelPlugin,
cfg: OpenClawConfig,
): ChannelMessageActionName[] {
if (!plugin.actions?.listActions) return [];
if (!plugin.actions?.listActions) {
return [];
}
try {
const listed = plugin.actions.listActions({ cfg });
return Array.isArray(listed) ? listed : [];
@@ -89,7 +105,9 @@ function runPluginListActions(
function logListActionsError(pluginId: string, err: unknown) {
const message = err instanceof Error ? err.message : String(err);
const key = `${pluginId}:${message}`;
if (loggedListActionErrors.has(key)) return;
if (loggedListActionErrors.has(key)) {
return;
}
loggedListActionErrors.add(key);
const stack = err instanceof Error && err.stack ? err.stack : null;
const details = stack ?? message;