Skip to content

refactor(xtask): index audit report entries with one keyed helper - #185

Merged
kirillDevPro merged 1 commit into
masterfrom
lane/refactor-2026-11-28
Nov 28, 2026
Merged

kirillDevPro merged 1 commit into
masterfrom
lane/refactor-2026-11-28

Conversation

@kirillDevPro

Copy link
Copy Markdown
Collaborator

Refactor lane.

Signal: duplicated logic. Three private functions in
xtask/src/component_audit/reporting.rs computed the same thing - map a
slice of report entries into a BTreeMap keyed by a string field -
differing only in the field read:

  • keyed_components (old reporting.rs:91, key entry.concept)
  • keyed_metrics (old reporting.rs:99, key entry.id)
  • keyed_contracts (old reporting.rs:107, key entry.id)
    They are replaced by one generic keyed_by(entries, key) at
    reporting.rs:91; the six call sites in compare_with_baseline
    (reporting.rs:24, 25, 49, 50, 67, 68) pass the same key field each old
    function used. Sorted iteration, last-entry-wins on a duplicate key and
    the order of reported failures are unchanged. No public item changes.

Lines: reporting.rs 144 -> 125 (13 added, 32 removed).

Tests covering the change: the six compare_with_baseline tests in
xtask/src/component_audit/reporting/tests.rs (component removed, class
change, guarded and informational metrics, contract regressions), all
green before and after, untouched. Re-run: cargo test -p xtask
(30 passed); cargo xtask component-audit --check-baseline (PASS);
cargo fmt --all and cargo clippy -p xtask --all-targets (no new
warning).

Reviewer: Codex. It confirmed the duplication is real and found no
changed key, ordering, duplicate handling or public item; its only
note was that panic backtrace line numbers in print_human_report move,
which any edit of the file does and no caller observes.

Refactor lane.

Signal: duplicated logic. Three private functions in
xtask/src/component_audit/reporting.rs computed the same thing - map a
slice of report entries into a BTreeMap keyed by a string field -
differing only in the field read:
- keyed_components (old reporting.rs:91, key entry.concept)
- keyed_metrics (old reporting.rs:99, key entry.id)
- keyed_contracts (old reporting.rs:107, key entry.id)
They are replaced by one generic keyed_by(entries, key) at
reporting.rs:91; the six call sites in compare_with_baseline
(reporting.rs:24, 25, 49, 50, 67, 68) pass the same key field each old
function used. Sorted iteration, last-entry-wins on a duplicate key and
the order of reported failures are unchanged. No public item changes.

Lines: reporting.rs 144 -> 125 (13 added, 32 removed).

Tests covering the change: the six compare_with_baseline tests in
xtask/src/component_audit/reporting/tests.rs (component removed, class
change, guarded and informational metrics, contract regressions), all
green before and after, untouched. Re-run: cargo test -p xtask
(30 passed); cargo xtask component-audit --check-baseline (PASS);
cargo fmt --all and cargo clippy -p xtask --all-targets (no new
warning).

Reviewer: Codex. It confirmed the duplication is real and found no
changed key, ordering, duplicate handling or public item; its only
note was that panic backtrace line numbers in print_human_report move,
which any edit of the file does and no caller observes.
@kirillDevPro
kirillDevPro merged commit c1ff98a into master Nov 28, 2026
4 checks passed
@kirillDevPro
kirillDevPro deleted the lane/refactor-2026-11-28 branch November 28, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant