Skip to content

Debug leftovers: debugger, breakpoint(), print("here"), print(f"{x=}"), dbg! ​

Code nobody needs: one of the ways AI coding agents bloat software, from lessloc's pattern catalog. lessloc catches it as debug-leftover.

What makes debug leftovers a bad practice? ​

The standards that call it a bad practice: CWE-489 Active Debug Code; ESLint no-debugger; Sonar S4507; clippy dbg_macro.

What does lessloc do about debug leftovers? ​

lessloc catches it as debug-leftover. It is judged at turn end, because mid-work the print may still be in use.

  • debug-leftover (tier 1): debugger, breakpoint(), pdb.set_trace(), or a debug print such as print("here"). Judged when the turn ends.

Examples ​

Caught as debug-leftover:

js
export function total(xs) {
  debugger;
  console.log("here");
  return xs.length;
}

Written well:

js
export function total(xs) {
  console.log(`total of ${xs.length} items`);
  return xs.length;
}

Caught as debug-leftover:

python
def total(xs):
    breakpoint()
    print(f"{xs=}")
    return len(xs)

Written well:

python
def total(xs):
    print(f"{len(xs)} items")
    return len(xs)

The other patterns in Code nobody needs:

Released under the Apache-2.0 license. · llms.txt