Skip to main content
New aislop v0.9.4: four new Python rules from the SlopCodeBench paper, plus a CLI star prompt and GitHub Discussions. Read more →
ai-slop/constant-condition manual fix

Constant condition.

An `if` or `while` whose condition is a constant — `if (true)`, `while (false)`, `if (1)` — leaving a dead branch in the source.

Bad — what an agent ships
if (true) {
  doStuff()
} else {
  // never runs
  fallback()
}
Good — what aislop hands back
// just call it
doStuff()

// or, if there's a real toggle, make it real:
if (config.featureEnabled) {
  doStuff()
} else {
  fallback()
}

Agents leave debug toggles or temporary feature flags hard-coded after testing. Half the branch is unreachable; the reader has to figure out which half is real.

How this rule is justified.

Rule id

ai-slop/constant-condition

Enforcing engine

ai-slop

Detector strategy

Deterministic AST match: flags conditionals whose test evaluates to a compile-time constant.

Legitimate code that is NOT flagged

Intentional infinite loops (`while (true)` with a break) and constants resolved from real configuration are not flagged.

Evidence

Provenance: repeated across public scans as a hard-coded debug toggle left behind.