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

@@ -76,7 +76,9 @@ export function buildEmbeddedRunPayloads(params: {
: null;
const normalizedErrorText = errorText ? normalizeTextForComparison(errorText) : null;
const genericErrorText = "The AI service returned an error. Please try again.";
if (errorText) replyItems.push({ text: errorText, isError: true });
if (errorText) {
replyItems.push({ text: errorText, isError: true });
}
const inlineToolResults =
params.inlineToolResultsAllowed && params.verboseLevel !== "off" && params.toolMetas.length > 0;
@@ -110,31 +112,51 @@ export function buildEmbeddedRunPayloads(params: {
params.lastAssistant && params.reasoningLevel === "on"
? formatReasoningMessage(extractAssistantThinking(params.lastAssistant))
: "";
if (reasoningText) replyItems.push({ text: reasoningText });
if (reasoningText) {
replyItems.push({ text: reasoningText });
}
const fallbackAnswerText = params.lastAssistant ? extractAssistantText(params.lastAssistant) : "";
const shouldSuppressRawErrorText = (text: string) => {
if (!lastAssistantErrored) return false;
if (!lastAssistantErrored) {
return false;
}
const trimmed = text.trim();
if (!trimmed) return false;
if (!trimmed) {
return false;
}
if (errorText) {
const normalized = normalizeTextForComparison(trimmed);
if (normalized && normalizedErrorText && normalized === normalizedErrorText) return true;
if (trimmed === genericErrorText) return true;
if (normalized && normalizedErrorText && normalized === normalizedErrorText) {
return true;
}
if (trimmed === genericErrorText) {
return true;
}
}
if (rawErrorMessage && trimmed === rawErrorMessage) {
return true;
}
if (formattedRawErrorMessage && trimmed === formattedRawErrorMessage) {
return true;
}
if (rawErrorMessage && trimmed === rawErrorMessage) return true;
if (formattedRawErrorMessage && trimmed === formattedRawErrorMessage) return true;
if (normalizedRawErrorText) {
const normalized = normalizeTextForComparison(trimmed);
if (normalized && normalized === normalizedRawErrorText) return true;
if (normalized && normalized === normalizedRawErrorText) {
return true;
}
}
if (normalizedFormattedRawErrorMessage) {
const normalized = normalizeTextForComparison(trimmed);
if (normalized && normalized === normalizedFormattedRawErrorMessage) return true;
if (normalized && normalized === normalizedFormattedRawErrorMessage) {
return true;
}
}
if (rawErrorFingerprint) {
const fingerprint = getApiErrorPayloadFingerprint(trimmed);
if (fingerprint && fingerprint === rawErrorFingerprint) return true;
if (fingerprint && fingerprint === rawErrorFingerprint) {
return true;
}
}
return isRawApiErrorPayload(trimmed);
};
@@ -222,8 +244,12 @@ export function buildEmbeddedRunPayloads(params: {
audioAsVoice: item.audioAsVoice || Boolean(hasAudioAsVoiceTag && item.media?.length),
}))
.filter((p) => {
if (!p.text && !p.mediaUrl && (!p.mediaUrls || p.mediaUrls.length === 0)) return false;
if (p.text && isSilentReplyText(p.text, SILENT_REPLY_TOKEN)) return false;
if (!p.text && !p.mediaUrl && (!p.mediaUrls || p.mediaUrls.length === 0)) {
return false;
}
if (p.text && isSilentReplyText(p.text, SILENT_REPLY_TOKEN)) {
return false;
}
return true;
});
}