What mehen emits
Published on the file’s root space and, span-scoped, on every function and closure space in
the metric tree — the per-function values are what make the numbers actionable (and what the
planned CRAP composite consumes).
Semantics
- Instrumentable lines only. The denominator is the lines the coverage tool instrumented —
blank lines, comments, and non-executable declarations are excluded by the producing tool,
not by mehen. LCOV
DArecords with negative counts (non-instrumentable markers some instrumenters emit) are dropped. - Hit means hit at least once. Execution counts are preserved internally (and used for max-merging), but the rate counts a line as covered at any count ≥ 1 — matching how every producing tool defines the percentage.
- Statements fold to lines. Istanbul statement maps and Go basic blocks resolve to line numbers; multiple statements on one line keep the maximum count.
- Unmeasured ≠ 0%. A file absent from every report, or a function span containing no
instrumented lines (macro-generated code,
#[cfg(test)]items, dead-code-eliminated functions), publishes nothing. Only genuinely instrumented-but-unexecuted code reads0. - Per-function attribution is line-range based. A function space spanning lines 10–24 aggregates the report’s records for those lines. Line ranges come from mehen’s real parsers, so the attribution is exact for the function body; a multi-line signature counts from the declaration line the parser assigns.
How to read it
Google’s large-scale guidance is a useful calibration: they characterize 60% as acceptable, 75%
as commendable, and 90% as exemplary — while explicitly warning against chasing the number for
its own sake, because the marginal lines are usually the least valuable to cover. The empirical
literature agrees from the other side: Inozemtseva & Holmes found coverage only weakly-to-
moderately correlated with suite effectiveness once suite size is controlled, so a high
percentage must never be read as proof of a strong suite.
Gating
coverage.line threshold is itself the trigger for
report ingestion — no flag needed in CI. Unmeasured files
skip the gate (never a fabricated violation); genuinely 0%-covered files fail it.
See also
- Branch coverage — the stricter criterion.
- Function coverage — the coarser one.
- Cognitive complexity — the number to cross line coverage with.
References
- Ivanković, M., Petrović, G., Just, R., & Fraser, G. (2019). Code coverage at Google. ESEC/FSE 2019.
- Inozemtseva, L., & Holmes, R. (2014). Coverage is not strongly correlated with test suite effectiveness. ICSE 2014.
- Marick, B. (1999). How to misuse code coverage.
- Fowler, M. (2012). TestCoverage. martinfowler.com.
- Savoia, A., & Evans, B. (2007). The CRAP metric — the complexity × (1 − coverage)³ composite the per-function values feed.