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

@@ -60,7 +60,9 @@ export class IMessageRpcClient {
}
async start(): Promise<void> {
if (this.child) return;
if (this.child) {
return;
}
const args = ["rpc"];
if (this.dbPath) {
args.push("--db", this.dbPath);
@@ -73,14 +75,18 @@ export class IMessageRpcClient {
this.reader.on("line", (line) => {
const trimmed = line.trim();
if (!trimmed) return;
if (!trimmed) {
return;
}
this.handleLine(trimmed);
});
child.stderr?.on("data", (chunk) => {
const lines = chunk.toString().split(/\r?\n/);
for (const line of lines) {
if (!line.trim()) continue;
if (!line.trim()) {
continue;
}
this.runtime?.error?.(`imsg rpc: ${line.trim()}`);
}
});
@@ -102,7 +108,9 @@ export class IMessageRpcClient {
}
async stop(): Promise<void> {
if (!this.child) return;
if (!this.child) {
return;
}
this.reader?.close();
this.reader = null;
this.child.stdin?.end();
@@ -113,7 +121,9 @@ export class IMessageRpcClient {
this.closed,
new Promise<void>((resolve) => {
setTimeout(() => {
if (!child.killed) child.kill("SIGTERM");
if (!child.killed) {
child.kill("SIGTERM");
}
resolve();
}, 500);
}),
@@ -175,8 +185,12 @@ export class IMessageRpcClient {
if (parsed.id !== undefined && parsed.id !== null) {
const key = String(parsed.id);
const pending = this.pending.get(key);
if (!pending) return;
if (pending.timer) clearTimeout(pending.timer);
if (!pending) {
return;
}
if (pending.timer) {
clearTimeout(pending.timer);
}
this.pending.delete(key);
if (parsed.error) {
@@ -184,11 +198,15 @@ export class IMessageRpcClient {
const details = parsed.error.data;
const code = parsed.error.code;
const suffixes = [] as string[];
if (typeof code === "number") suffixes.push(`code=${code}`);
if (typeof code === "number") {
suffixes.push(`code=${code}`);
}
if (details !== undefined) {
const detailText =
typeof details === "string" ? details : JSON.stringify(details, null, 2);
if (detailText) suffixes.push(detailText);
if (detailText) {
suffixes.push(detailText);
}
}
const msg = suffixes.length > 0 ? `${baseMessage}: ${suffixes.join(" ")}` : baseMessage;
pending.reject(new Error(msg));
@@ -208,7 +226,9 @@ export class IMessageRpcClient {
private failAll(err: Error) {
for (const [key, pending] of this.pending.entries()) {
if (pending.timer) clearTimeout(pending.timer);
if (pending.timer) {
clearTimeout(pending.timer);
}
pending.reject(err);
this.pending.delete(key);
}