Skip to main content
New aislop v0.13.1 patch — calibrates hidden-fallback detection and fixes regex comment-masker false positives. Read the changelog →
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.

Flagged shape and clean shape.

Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.

Flagged example
if (true) {
  doStuff()
} else {
  // never runs
  fallback()
}
Why this trips

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

Clean example
if (config.featureEnabled) {
  doStuff()
} else {
  fallback()
}
What changed

Remove hard-coded debug branches or replace them with real configuration. The condition should describe runtime behavior, not a temporary toggle that got left behind.

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.