#[non_exhaustive]pub struct MetricInfo {
pub id: &'static str,
pub family: &'static str,
pub long_description: &'static str,
pub direction: Direction,
pub skip_at_unit: bool,
pub scope: MetricScope,
}Expand description
Catalog entry for one offender-emitting sub-metric id.
The id is the dotted key the threshold engine emits for an
offender (halstead.volume); family groups ids under a top-level
metric (halstead) and must match a MetricFamily::name.
#[non_exhaustive]: these are read-only records the library
constructs (downstream consumers read fields, never build them), so
a new field can be added in a future minor without a SemVer break.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: &'static strDotted offender id, e.g. "halstead.volume" or "cognitive".
family: &'static strTop-level family this id belongs to, e.g. "halstead".
long_description: &'static strLong-form sentence for SARIF rule.shortDescription.text and
the Code Climate description prefix.
direction: DirectionWhether a higher or lower value is the unhealthy direction.
skip_at_unit: boolWhether the metric’s JSON headline is an aggregate across
descendant spaces (a sum/*_sum field) that does not match
the CLI threshold accessor’s per-space scalar at any interior
space.
true for the five metrics whose serialized headline diverges
from the per-space accessor — cognitive, cyclomatic,
cyclomatic.modified, abc (#441) and, since #1196 moved its
gate onto the callable’s own parameter list, nargs. The
aggregate is at least as large everywhere and equal only where
the descendants contribute nothing — always at a leaf space (no
descendant function/closure spaces), and incidentally at an
interior one whose descendants all score zero.
This flag describes the sum/*_sum/total aggregate field,
which still diverges. As of #958 (and #1236 for nargs) the wire
shape also serializes each of these metrics’ per-space own
value (cyclomatic.value, cyclomatic.modified.value,
cognitive.value, abc.value, nargs.value), so a JSON-walking
front-end no longer needs this flag to stay correct: it reads the
own value directly and emits at every space exactly like the CLI.
The Python to_sarif binding was switched to that path in #958;
before it, the binding emitted these only at leaf spaces to avoid
subtree-wide values masquerading as per-space findings the CLI
never produces (#855). The flag name retains its original
unit-only framing.
The flag is not derivable from the JSON path string: nexits
also serialises a sum field, but its CLI accessor (nexits_sum())
reads that same aggregate, so it does not diverge and is false.
The divergence is between the JSON field and the CLI accessor,
which only this registry now records once for both front-ends to
share (#442).
scope: MetricScopeThe space kind this metric’s threshold gates (issue #969). Both
the CLI threshold engine and the Python to_sarif binding read
this to skip spaces a metric does not measure, so a metric’s
file-wide or impl-wide aggregate never fires as a per-function
limit. See MetricScope.