Commented-out code
Commented-out code. Commented-out code. Version control keeps old code; this just rots.
This is how the comment reads inline, under the flagged line.
Why it matters
Dead code in comments confuses readers about what runs and never gets updated with the code around it.
What to do
Delete it. Git has it if you need it back.
Examples
// const old = computeLegacy(x); const v = compute(x);
const v = compute(x);
What it catches
It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python, Go, Rust, Java, C and similar. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
// const x = load();
// doThing(a, b);
src/app.py
# return compute(x) x = 1
Left alone
// Load lazily so startup stays fast.
src/app.py
# return early when empty x = 1
Research
Commented-out code. Git already keeps old code, and the comment rots.
- Ruff rules
- Detecting AI slop in codebases
- owner's code bar
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"commented-out-code"
],
"severity": {
"commented-out-code": "medium"
}
}
}