Skip to content

Extract a metric registry when a second language-specific metric lands #39

Closed

Description

@ElbertePlinio

Found while closing #6, whose acceptance list included "adding a per-language metric no longer requires editing a hard-coded metric array". That registry was deferred in #9 and again in #28 because only one metric, widget_depth, is language-specific, so the abstraction had no second user.

Today a new metric means editing parallel name lists by hand: LIMIT_KEYS in crates/core/src/config.rs, the limit and value arrays in crates/core/src/scan.rs (add_violations and its helpers), the metric match in crates/core/src/baseline.rs, plus the Limits, LimitOverrides, and FunctionMetrics fields. Missing one compiles fine and silently drops the metric from that path.

Trigger: originally "wait for a second language-specific metric". Overridden on 2026-09-30 by the maintainer; build it now.

Acceptance

  • One definition per metric drives config key validation, per-language applicability, violation emission, and baseline lookup.
  • Adding a metric that applies to only some languages touches that definition and its traversal, not the name lists above. Any place a new metric still needs wiring (a struct field, a serde key) fails to compile instead of silently dropping it.
  • JSON output, config shape, and exit codes are unchanged, and every existing golden fixture passes unmodified.

Checklist

  • Metric enum with the metric list, names, and applicability (all units, not Svelte templates, Dart build only)
  • Config key validation, limits_for, effective_limits, add_violations, and MetricValues driven by it
  • Unit test that every Metric round-trips through config keys, Limits, and MetricValues
  • Tests, clippy, fmt, coverage floor, PickCheck green; JSON and golden fixtures unchanged

Activity

  1. added
    enhancement
    on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions