mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 22:41:25 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -16,23 +16,33 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
}
|
||||
|
||||
function collectScopes(value: unknown, into: string[]) {
|
||||
if (!value) return;
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
for (const entry of value) {
|
||||
if (typeof entry === "string" && entry.trim()) into.push(entry.trim());
|
||||
if (typeof entry === "string" && entry.trim()) {
|
||||
into.push(entry.trim());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
const raw = value.trim();
|
||||
if (!raw) return;
|
||||
if (!raw) {
|
||||
return;
|
||||
}
|
||||
const parts = raw.split(/[,\s]+/).map((part) => part.trim());
|
||||
for (const part of parts) {
|
||||
if (part) into.push(part);
|
||||
if (part) {
|
||||
into.push(part);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!isRecord(value)) return;
|
||||
if (!isRecord(value)) {
|
||||
return;
|
||||
}
|
||||
for (const entry of Object.values(value)) {
|
||||
if (Array.isArray(entry) || typeof entry === "string") {
|
||||
collectScopes(entry, into);
|
||||
@@ -45,7 +55,9 @@ function normalizeScopes(scopes: string[]) {
|
||||
}
|
||||
|
||||
function extractScopes(payload: unknown): string[] {
|
||||
if (!isRecord(payload)) return [];
|
||||
if (!isRecord(payload)) {
|
||||
return [];
|
||||
}
|
||||
const scopes: string[] = [];
|
||||
collectScopes(payload.scopes, scopes);
|
||||
collectScopes(payload.scope, scopes);
|
||||
@@ -59,7 +71,9 @@ function extractScopes(payload: unknown): string[] {
|
||||
}
|
||||
|
||||
function readError(payload: unknown): string | undefined {
|
||||
if (!isRecord(payload)) return undefined;
|
||||
if (!isRecord(payload)) {
|
||||
return undefined;
|
||||
}
|
||||
const error = payload.error;
|
||||
return typeof error === "string" && error.trim() ? error.trim() : undefined;
|
||||
}
|
||||
@@ -94,7 +108,9 @@ export async function fetchSlackScopes(
|
||||
return { ok: true, scopes, source: method };
|
||||
}
|
||||
const error = readError(result);
|
||||
if (error) errors.push(`${method}: ${error}`);
|
||||
if (error) {
|
||||
errors.push(`${method}: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user