mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:08:25 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -7,12 +7,20 @@ function normalizeFlag(value: string): string {
|
||||
}
|
||||
|
||||
function parseEnvFlags(raw?: string): string[] {
|
||||
if (!raw) return [];
|
||||
if (!raw) {
|
||||
return [];
|
||||
}
|
||||
const trimmed = raw.trim();
|
||||
if (!trimmed) return [];
|
||||
if (!trimmed) {
|
||||
return [];
|
||||
}
|
||||
const lowered = trimmed.toLowerCase();
|
||||
if (["0", "false", "off", "none"].includes(lowered)) return [];
|
||||
if (["1", "true", "all", "*"].includes(lowered)) return ["*"];
|
||||
if (["0", "false", "off", "none"].includes(lowered)) {
|
||||
return [];
|
||||
}
|
||||
if (["1", "true", "all", "*"].includes(lowered)) {
|
||||
return ["*"];
|
||||
}
|
||||
return trimmed
|
||||
.split(/[,\s]+/)
|
||||
.map(normalizeFlag)
|
||||
@@ -24,7 +32,9 @@ function uniqueFlags(flags: string[]): string[] {
|
||||
const out: string[] = [];
|
||||
for (const flag of flags) {
|
||||
const normalized = normalizeFlag(flag);
|
||||
if (!normalized || seen.has(normalized)) continue;
|
||||
if (!normalized || seen.has(normalized)) {
|
||||
continue;
|
||||
}
|
||||
seen.add(normalized);
|
||||
out.push(normalized);
|
||||
}
|
||||
@@ -42,20 +52,32 @@ export function resolveDiagnosticFlags(
|
||||
|
||||
export function matchesDiagnosticFlag(flag: string, enabledFlags: string[]): boolean {
|
||||
const target = normalizeFlag(flag);
|
||||
if (!target) return false;
|
||||
if (!target) {
|
||||
return false;
|
||||
}
|
||||
for (const raw of enabledFlags) {
|
||||
const enabled = normalizeFlag(raw);
|
||||
if (!enabled) continue;
|
||||
if (enabled === "*" || enabled === "all") return true;
|
||||
if (!enabled) {
|
||||
continue;
|
||||
}
|
||||
if (enabled === "*" || enabled === "all") {
|
||||
return true;
|
||||
}
|
||||
if (enabled.endsWith(".*")) {
|
||||
const prefix = enabled.slice(0, -2);
|
||||
if (target === prefix || target.startsWith(`${prefix}.`)) return true;
|
||||
if (target === prefix || target.startsWith(`${prefix}.`)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (enabled.endsWith("*")) {
|
||||
const prefix = enabled.slice(0, -1);
|
||||
if (target.startsWith(prefix)) return true;
|
||||
if (target.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (enabled === target) {
|
||||
return true;
|
||||
}
|
||||
if (enabled === target) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user