CLOC (Comment Lines of Code) counts lines that contain at least one comment token. Mehen does not distinguish line, block, or doc comments in the headline metric — they all contribute one line per physical line they occupy.Documentation Index
Fetch the complete documentation index at: https://mehen.ophi.dev/llms.txt
Use this file to discover all available pages before exploring further.
What mehen emits
| Key | Type | Description |
|---|---|---|
loc.cloc | int | Comment lines (line + block + doc comments). |
How it is computed
A line counts toward CLOC when the parser reports at least one comment trivia token on it. A pure comment line (e.g., a// line in Rust or a # line in Python) counts once. Mixed lines (code
followed by an inline comment) count toward both PLOC and CLOC.
When it is useful
- Comment density —
cloc / (cloc + ploc)is a coarse proxy for documentation effort. - Generated code detection — heavily generated files often have unusually low or unusually high comment density.
- Maintainability — the Maintainability Index
mi.originalvariant uses comment count as one of its inputs.
A high CLOC is not automatically a good thing. Stale, copy-pasted, or boilerplate comments hurt
maintainability. Read CLOC alongside Cognitive complexity — clear code with
few comments often beats opaque code with many.
References
- Park, R. E. (1992). Software Size Measurement: A Framework for Counting Source Statements. CMU/SEI-92-TR-20 — comment-line conventions. SEI report.
- Sonar:
comment_linesandcomment_lines_density.
See also
- LOC family — overview.
- PLOC — physical instruction lines.
- Maintainability Index — uses comment counts.