Skip to main content

resolve_selector

Function resolve_selector 

Source
pub fn resolve_selector(name: &str) -> Result<Metric, UnknownSelectorError>
Expand description

Resolve a metric selector to the Metric family that computes it.

A selector is any name bca metrics --metrics accepts:

  • a family name (loc, cyclomatic), the Metric Display spelling;
  • a bca list-metrics row name (sloc, dloc, …), which selects the family that owns the row;
  • a dotted METRICS id (cyclomatic.modified, loc.sloc, mi.original), which selects its family.

Selection is family-granular, as the walk computes whole families: "dloc" and "loc" both select Metric::Loc, and nothing narrows the output to the named field. Matching is strict lowercase, like Metric’s FromStr.

§Errors

UnknownSelectorError when name is none of the above. It carries the closest selector_names as a did-you-mean hint.