No `if (false)` / `if (true)` debug blocks
Why it matters
if (false) blocks are code that never executes — AI commonly uses them to 'disable' logic without deleting it, leaving dead branches that confuse static analysis, obscure actual code paths, and make security reviews unreliable. if (true) debug toggles expose internal state (request bodies, database rows, session tokens) to logs that may be shipped to log aggregators, error trackers, or observability platforms. CWE-489 (Active Debug Code) applies: these patterns signal that the code was never cleaned up after prototyping and likely contains other unfinished logic nearby.
Severity rationale
Medium because `if (true)` blocks actively leak internal data to logs, while `if (false)` blocks signal incomplete implementation that auditors and attackers both use to locate unfinished security controls.
Remediation
Delete if (false) blocks entirely — they are dead code with no runtime value. For if (true) debug toggles, replace them with environment-gated flags in src/lib/logger.ts or equivalent:
// Remove these:
if (false) { doOldThing() }
if (true) { console.log('debug:', sensitiveData) }
// Replace debug logging with:
if (process.env.DEBUG === 'true') {
console.log('debug:', safeToLogData)
}
// Or use a structured logger that respects log level:
import { logger } from '@/lib/logger'
logger.debug({ event: 'auth-check', userId }) // no raw data
Search non-test source files for the literal strings if (false), if(false), if (true), if(true) and remove every match.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the WIP-in-Production Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-489 — Active Debug Code
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-slop-half-finished·automated