#[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 four metrics whose serialized JSON value diverges
from the per-space accessor — cognitive, cyclomatic,
cyclomatic.modified, and abc (#441). The aggregate equals the
per-space scalar only at a leaf space (no descendant
function/closure spaces); at any interior space — the file-level
unit or a container with descendants — it is larger.
This flag describes the sum/*_sum aggregate field, which
still diverges. As of #958 the wire shape also serializes each
of these four metrics’ per-space own value (cyclomatic.value,
cyclomatic.modified.value, cognitive.value, abc.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.
Trait Implementations§
Source§impl Clone for MetricInfo
impl Clone for MetricInfo
Source§fn clone(&self) -> MetricInfo
fn clone(&self) -> MetricInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more