Skip to main content

Module metrics

Module metrics 

Source
Expand description

Language-neutral complexity-metric scaffolding: the computed-value carrier FileMetrics, the writer write_metrics (omit-at + LOC/Halstead gating), the no-signal values [metric_omit_at], and the metric attribute catalog metric_specs. The sibling coupling_specs lives alongside it; both are merged into the snapshot’s node-attribute dictionary.

The per-language engines that produce a FileMetrics live in the language crates — rust_ts in code-ranker-plugin-rust, python_ts in code-ranker-plugin-python, ecmascript_ts in code-ranker-ecmascript-core. Each plugin computes a FileMetrics with its own engine and calls write_metrics here. This module names no language and pulls in no grammar.

Structs§

FileMetrics
The per-file complexity metric values a language engine computes, in the canonical key set this crate writes. Engines fill the fields they support and leave the rest at 0.0 (e.g. tloc is non-zero only for Rust, where inline #[cfg(test)] items are stripped). write_metrics turns this into node attributes, applying each key’s omit_at and the LOC / Halstead gating.

Functions§

metric_specs
The complexity metric attribute dictionary and its groups, fully enriched (label/name/short/description/formula/calc/direction) so the UI hardcodes no metric. The orchestrator merges these into each level’s node_attributes / attribute_groups (then prunes to keys actually present) and overlays language thresholds. Coupling/cycle specs live in code-ranker-graph.
write_metrics
Write the metric attributes for one file node from a computed FileMetrics. Each value is dropped at its omit_at ([metric_omit_at]); the LOC block is gated on sloc > 0 and the Halstead block on volume > 0. The same omit values are published on the specs (metric_specs), so emission and the declared spec never drift. Called by each language plugin after its engine produces the values.