Expand description
Canonical metric catalog: offender sub-metric ids with their
long-form sentences and metric_catalog::Direction, plus the
family view rendered by bca list-metrics. Single source of truth
shared by the library’s offender formatters and the CLI’s threshold
engine, which pins its extractor ids to metric_catalog::METRICS
via a parity test.
Single source of truth for the metric catalog.
Before this module existed, the same set of offender metric ids was
hand-maintained in three places — output::sarif’s rule
descriptions, the CLI’s threshold extractor table, and a third copy
inside a “does every extractor have a description” test — plus a
fourth, differently-shaped table powering bca list-metrics. Those
tables drifted: ten of twenty-one rule-description keys once failed
to match any real offender id and went unnoticed for two model
versions.
METRICS is now the canonical
list of offender sub-metric ids (halstead.volume, mi.original,
…) together with their long-form sentences and
Direction.
FAMILIES is the canonical view
that bca list-metrics renders. The library’s offender formatters
(output::sarif, output::code_climate) read METRICS; the
CLI’s threshold engine keys its extractor table off the same ids and
a parity test pins the two id-sets together, so a new metric cannot
ship with a half-updated catalog.
Structs§
- Metric
Family - A top-level metric family as surfaced by
bca list-metrics. - Metric
Info - Catalog entry for one offender-emitting sub-metric id.
- Metric
Row - A
bca list-metricsrow: the bare name printed innamesmode and the one-line summary printed indescriptionsmode.
Enums§
- Direction
- Which direction of a metric’s value is unhealthy.
- Metric
Scope - The space kind a metric’s threshold is meaningful on (issue #969).
Constants§
- FAMILIES
- Canonical
bca list-metricsview. Family summaries moved here verbatim from the CLI’s former hand-maintained catalog. Declaration order is thelist-metricsprint order. - METRICS
- Canonical offender sub-metric catalog. Long-form sentences and the
mi.*lower-is-worse direction moved here verbatim from the formeroutput::rule_descriptionstable.
Functions§
- lookup
- Catalog entry for a known offender id, or
None. Callers pick their own fallback for unknown ids (SARIF emits the raw id; Code Climate falls through to its default message). - lower_
is_ worse - Whether a lower value of the metric
idis the unhealthy direction (themi.*Maintainability Index family). The threshold gate, the Code Climate severity-ratio inversion, and the SARIF/offender wording all consult this so they never drift from one another. An id the catalog does not know defaults to higher-is-worse — the same fallback every offender formatter already uses (#698). - scope
- The
MetricScopeof metricid— the space kind its threshold gates (issue #969).Nonefor an id the catalog does not know; both front-ends treat an unknown id as a usage error before reaching here, so theNonearm is only a defensive fallback.