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

@@ -81,7 +81,9 @@ export function normalizeToolName(name: string) {
}
export function normalizeToolList(list?: string[]) {
if (!list) return [];
if (!list) {
return [];
}
return list.map(normalizeToolName).filter(Boolean);
}
@@ -118,11 +120,17 @@ export function expandToolGroups(list?: string[]) {
export function collectExplicitAllowlist(policies: Array<ToolPolicyLike | undefined>): string[] {
const entries: string[] = [];
for (const policy of policies) {
if (!policy?.allow) continue;
if (!policy?.allow) {
continue;
}
for (const value of policy.allow) {
if (typeof value !== "string") continue;
if (typeof value !== "string") {
continue;
}
const trimmed = value.trim();
if (trimmed) entries.push(trimmed);
if (trimmed) {
entries.push(trimmed);
}
}
}
return entries;
@@ -136,7 +144,9 @@ export function buildPluginToolGroups<T extends { name: string }>(params: {
const byPlugin = new Map<string, string[]>();
for (const tool of params.tools) {
const meta = params.toolMeta(tool);
if (!meta) continue;
if (!meta) {
continue;
}
const name = normalizeToolName(tool.name);
all.push(name);
const pluginId = meta.pluginId.toLowerCase();
@@ -151,7 +161,9 @@ export function expandPluginGroups(
list: string[] | undefined,
groups: PluginToolGroups,
): string[] | undefined {
if (!list || list.length === 0) return list;
if (!list || list.length === 0) {
return list;
}
const expanded: string[] = [];
for (const entry of list) {
const normalized = normalizeToolName(entry);
@@ -177,7 +189,9 @@ export function expandPolicyWithPluginGroups(
policy: ToolPolicyLike | undefined,
groups: PluginToolGroups,
): ToolPolicyLike | undefined {
if (!policy) return undefined;
if (!policy) {
return undefined;
}
return {
allow: expandPluginGroups(policy.allow, groups),
deny: expandPluginGroups(policy.deny, groups),
@@ -205,8 +219,12 @@ export function stripPluginOnlyAllowlist(
entry === "group:plugins" || pluginIds.has(entry) || pluginTools.has(entry);
const expanded = expandToolGroups([entry]);
const isCoreEntry = expanded.some((tool) => coreTools.has(tool));
if (isCoreEntry) hasCoreEntry = true;
if (!isCoreEntry && !isPluginEntry) unknownAllowlist.push(entry);
if (isCoreEntry) {
hasCoreEntry = true;
}
if (!isCoreEntry && !isPluginEntry) {
unknownAllowlist.push(entry);
}
}
const strippedAllowlist = !hasCoreEntry;
// When an allowlist contains only plugin tools, we strip it to avoid accidentally
@@ -223,10 +241,16 @@ export function stripPluginOnlyAllowlist(
}
export function resolveToolProfilePolicy(profile?: string): ToolProfilePolicy | undefined {
if (!profile) return undefined;
if (!profile) {
return undefined;
}
const resolved = TOOL_PROFILES[profile as ToolProfileId];
if (!resolved) return undefined;
if (!resolved.allow && !resolved.deny) return undefined;
if (!resolved) {
return undefined;
}
if (!resolved.allow && !resolved.deny) {
return undefined;
}
return {
allow: resolved.allow ? [...resolved.allow] : undefined,
deny: resolved.deny ? [...resolved.deny] : undefined,