Repository navigation
refactor(xtask): index audit report entries with one keyed helper - #185
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.