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

@@ -38,7 +38,9 @@ const debugEmbeddings = isTruthyEnvValue(process.env.OPENCLAW_DEBUG_MEMORY_EMBED
const log = createSubsystemLogger("memory/embeddings");
const debugLog = (message: string, meta?: Record<string, unknown>) => {
if (!debugEmbeddings) return;
if (!debugEmbeddings) {
return;
}
const suffix = meta ? ` ${JSON.stringify(meta)}` : "";
log.raw(`${message}${suffix}`);
};
@@ -71,7 +73,9 @@ function getGeminiUploadUrl(baseUrl: string): string {
}
function splitGeminiBatchRequests(requests: GeminiBatchRequest[]): GeminiBatchRequest[][] {
if (requests.length <= GEMINI_BATCH_MAX_REQUESTS) return [requests];
if (requests.length <= GEMINI_BATCH_MAX_REQUESTS) {
return [requests];
}
const groups: GeminiBatchRequest[][] = [];
for (let i = 0; i < requests.length; i += GEMINI_BATCH_MAX_REQUESTS) {
groups.push(requests.slice(i, i + GEMINI_BATCH_MAX_REQUESTS));
@@ -218,7 +222,9 @@ async function fetchGeminiFileContent(params: {
}
function parseGeminiBatchOutput(text: string): GeminiBatchOutputLine[] {
if (!text.trim()) return [];
if (!text.trim()) {
return [];
}
return text
.split("\n")
.map((line) => line.trim())
@@ -272,7 +278,9 @@ async function waitForGeminiBatch(params: {
}
async function runWithConcurrency<T>(tasks: Array<() => Promise<T>>, limit: number): Promise<T[]> {
if (tasks.length === 0) return [];
if (tasks.length === 0) {
return [];
}
const resolvedLimit = Math.max(1, Math.min(limit, tasks.length));
const results: T[] = Array.from({ length: tasks.length });
let next = 0;
@@ -280,10 +288,14 @@ async function runWithConcurrency<T>(tasks: Array<() => Promise<T>>, limit: numb
const workers = Array.from({ length: resolvedLimit }, async () => {
while (true) {
if (firstError) return;
if (firstError) {
return;
}
const index = next;
next += 1;
if (index >= tasks.length) return;
if (index >= tasks.length) {
return;
}
try {
results[index] = await tasks[index]();
} catch (err) {
@@ -294,7 +306,9 @@ async function runWithConcurrency<T>(tasks: Array<() => Promise<T>>, limit: numb
});
await Promise.allSettled(workers);
if (firstError) throw firstError;
if (firstError) {
throw firstError;
}
return results;
}
@@ -308,7 +322,9 @@ export async function runGeminiEmbeddingBatches(params: {
concurrency: number;
debug?: (message: string, data?: Record<string, unknown>) => void;
}): Promise<Map<string, number[]>> {
if (params.requests.length === 0) return new Map();
if (params.requests.length === 0) {
return new Map();
}
const groups = splitGeminiBatchRequests(params.requests);
const byCustomId = new Map<string, number[]>();
@@ -373,7 +389,9 @@ export async function runGeminiEmbeddingBatches(params: {
for (const line of outputLines) {
const customId = line.key ?? line.custom_id ?? line.request_id;
if (!customId) continue;
if (!customId) {
continue;
}
remaining.delete(customId);
if (line.error?.message) {
errors.push(`${customId}: ${line.error.message}`);