Skip to main content

Module metric_catalog

Module metric_catalog 

Source
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§

MetricFamily
A top-level metric family as surfaced by bca list-metrics.
MetricInfo
Catalog entry for one offender-emitting sub-metric id.
MetricRow
A bca list-metrics row: the bare name printed in names mode and the one-line summary printed in descriptions mode.

Enums§

Direction
Which direction of a metric’s value is unhealthy.
MetricScope
The space kind a metric’s threshold is meaningful on (issue #969).

Constants§

FAMILIES
Canonical bca list-metrics view. Family summaries moved here verbatim from the CLI’s former hand-maintained catalog. Declaration order is the list-metrics print order.
METRICS
Canonical offender sub-metric catalog. Long-form sentences and the mi.* lower-is-worse direction moved here verbatim from the former output::rule_descriptions table.

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 id is the unhealthy direction (the mi.* 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 MetricScope of metric id — the space kind its threshold gates (issue #969). None for an id the catalog does not know; both front-ends treat an unknown id as a usage error before reaching here, so the None arm is only a defensive fallback.