Interpret key metrics — & when to worry¶
This page explains the metrics people ask about most, other than cyclomatic complexity (which has its own page). For each one: what it measures and what a high (or low) value tends to signal.
Where the thresholds come from
Understand is metric-agnostic — it reports the number and leaves the pass/fail line to you. The "watch for" cues below are directional, not limits. For concrete limits, adopt a published standard: the HIS metric set defines per-function limits, and the SEI cyclomatic risk bands are on the cyclomatic complexity page. Don't invent numbers.
Size: physical lines vs LOC/SLOC¶
Understand reports several line counts, and they mean different things:
| Metric | ID | Counts |
|---|---|---|
| Physical lines | CountLine |
Every line in the file/entity, including blanks and comments |
| Code lines (LOC / SLOC) | CountLineCode |
Lines that contain source code |
| Comment lines | CountLineComment |
Lines containing a comment |
| Blank lines | CountLineBlank |
Empty lines |
LOC and SLOC are the same metric here
Understand treats LOC and SLOC as lines containing code — that's CountLineCode, not
physical lines. There is no separate "SLOC" metric. A single line can be both code and comment, so
the counts overlap; see Why don't metrics add up?.
Inactive code isn't counted by default
These counts exclude inactive lines — code on the false side of a #if/#ifdef
(tracked separately as CountLineInactive). To
include them instead, C/C++ projects can use the WithInactive variants —
CountLineCodeWithInactive,
CountLineCommentWithInactive, and
CountLineBlankWithInactive.
Watch for: very large functions or files. Size alone isn't a defect, but big + complex together is the classic refactor candidate — the Metrics Treemap maps size and complexity at once.
CountPath (NPATH) — number of paths¶
CountPath counts the unique execution paths through a body of code (a.k.a. NPATH). It is not the
same as cyclomatic complexity: paths multiply. Each independent if roughly doubles the count, so
n sequential if statements give up to 2ⁿ paths — 29 of them already exceed half a billion.
Truncated at 999,999,999
Because the count grows exponentially, Understand caps CountPath at 999,999,999. A value at the
cap means "too many to enumerate," not an exact figure.
Watch for: a path count far higher than the cyclomatic number — it flags code that is hard to test exhaustively. (HIS sets a per-function limit of ≤ 80.)
MaxNesting — depth of nested control¶
MaxNesting is the deepest level of nested control constructs (if, for, while, switch, …) in a
function. Deeply nested code is harder to read and reason about than the same logic flattened with
early returns or extracted helpers.
Watch for: functions nested several levels deep — often a readability problem even when cyclomatic complexity looks acceptable.
Comment-to-code¶
RatioCommentToCode is the ratio of comment lines to code lines (it can exceed 100%). The HIS COMF
comment-density metric expresses the same idea and expects a minimum ratio.
Watch for: near-zero ratios on complex code (undocumented complexity). Very high ratios aren't automatically good either — commented-out code inflates the ratio.
Object-oriented metrics¶
These describe class design. Understand uses the standard Chidamber & Kemerer / Lorenz & Kidd definitions; the friendly research names appear in the metrics catalog.
| Metric | Understand ID | What it means | Watch for |
|---|---|---|---|
| DIT — Depth of Inheritance Tree | MaxInheritanceTree |
How deep the class sits in its inheritance hierarchy | Deep trees make behavior hard to trace and base classes fragile |
| CBO — Coupling Between Objects | CountClassCoupled |
How many other classes this one is coupled to (efferent coupling) | High coupling makes a class hard to change, reuse, or test in isolation |
| RFC — Response For a Class | CountDeclMethodAll |
Methods callable in response to a message (including inherited) | Large RFC means more to understand and test per class |
| LCOM — Lack of Cohesion | PercentLackOfCohesion |
100% minus average cohesion of the class's data members | High values suggest the class does unrelated jobs — a split candidate |
| WMC — Weighted Methods per Class | CountDeclMethod / SumCyclomatic |
Number (or complexity-weighted sum) of methods | A large, complex class concentrates risk |
| NOC — Number of Children | CountClassDerived |
Immediate subclasses | Many children means wide blast radius when the base changes |
General guidance: these metrics are most useful relatively — rank your classes by each one (see Rank & compare entities by a metric) and look at the outliers, rather than chasing an absolute number. High coupling and low cohesion together are the strongest "this class needs attention" signal — see Measure coupling & cohesion for the full workflow, including the fan-in/out metrics that apply beyond object-oriented code.
Turning "worry" into enforcement¶
When you want these to actually gate a build rather than inform a review, wire them to thresholds via CodeCheck or the HIS metric set, and surface the outliers visually with the Treemap and Heatmap.