ALL-COMM0002 · commented_out_code
Count comment groups that are source rather than prose.
This is a deterministic rule for all languages. Read its implementation.
Definition
Section titled “Definition”Report a contiguous comment group of at least minimum_lines lines whose text parses as source
in the language of the file it lives in. Commented-out code is dead weight that reads as
intent, since it survives refactors untouched, it is never compiled or tested, and every later
reader has to decide whether it matters. Version control already keeps the old version.
Evidence
Section titled “Evidence”Each finding records the comment range and its measured size. The value is the number of such groups.
Exceptions
Section titled “Exceptions”A tool directive, such as a suppression or a formatting marker, is excluded even when it
parses.
A documentation example inside a comment often parses too, so a project that keeps examples in
comments should raise minimum_lines or exclude those paths. Prose that happens to parse, such
as a single bare word, is why the default counts a group rather than a line.
Examples
Section titled “Examples”Three commented lines that reconstruct a former loop return 1. A comment reading # retry twice before giving up returns 0, and so does a suppression directive.
References
Section titled “References”- Generalizes SonarSource S125. Open reference
- Cites “Clean Code”, chapter on comments
- Cites “The Pragmatic Programmer”, on commented-out code