Summary
Cleanup surfaced while reviewing #544. Now that
big-code-analysis-cli/src/format_util.rs::strip_path_prefix and
lib.rs::{validate_output_path, write_output_or_stdout} exist as shared
helpers, three pre-existing inline duplicates should migrate onto them. This is
a pure DRY refactor — identical logic, no behavior change.
Duplication to consolidate
-
Path-prefix stripping (→ format_util::strip_path_prefix):
big-code-analysis-cli/src/exemptions.rs — private fn strip (~line 335)
and its 6 call sites (lines ~139, 163, 194, 214, 228, 275).
big-code-analysis-cli/src/markdown_report.rs — inline
file.strip_prefix(strip_prefix).unwrap_or(file) (~line 123).
All three are byte-identical to strip_path_prefix.
-
Output-path validate + write (→ validate_output_path /
write_output_or_stdout):
commands.rs::run_command_report (validate block ~1585, write ~1614).
commands.rs::run_command_exemptions (validate ~2158, write ~2194).
The new validate_output_path emits the same error wording
(--output must be a file path for \`, parent directory of
--output does not exist: …); confirm the write-path die_io` verb matches
the existing message before swapping (keep the message identical).
Acceptance
exemptions.rs and markdown_report.rs call strip_path_prefix; the private
strip fn is removed.
run_command_report/run_command_exemptions use the shared validate/write
helpers with byte-identical error messages.
- No behavior change; existing report/exemptions tests pass unmodified.
Found during #544 review; additive/non-breaking, no milestone.
Resolution
Fixed in e28cd710 (branch fix/issue-545). Pure DRY refactor, no
behavior change.
exemptions.rs: the 6 strip(...) call sites now call
format_util::strip_path_prefix; the private strip fn is removed.
markdown_report.rs: the inline
file.strip_prefix(strip_prefix).unwrap_or(file) in
extract_summaries now calls strip_path_prefix. The shared helper's
empty-prefix guard yields an identical result for the default empty
prefix.
commands.rs: run_command_report and run_command_exemptions now
use validate_output_path and write_output_or_stdout. Error wording
(--output must be a file path for \`, parent directory of
--output does not exist: …) and write verbs (write report to, write exemptions report to`) are byte-identical to the prior inline
blocks.
Validation: cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace --all-features
all pass. Existing report/exemptions tests pass unmodified; no .snap.new
drift.
Summary
Cleanup surfaced while reviewing #544. Now that
big-code-analysis-cli/src/format_util.rs::strip_path_prefixandlib.rs::{validate_output_path, write_output_or_stdout}exist as sharedhelpers, three pre-existing inline duplicates should migrate onto them. This is
a pure DRY refactor — identical logic, no behavior change.
Duplication to consolidate
Path-prefix stripping (→
format_util::strip_path_prefix):big-code-analysis-cli/src/exemptions.rs— privatefn strip(~line 335)and its 6 call sites (lines ~139, 163, 194, 214, 228, 275).
big-code-analysis-cli/src/markdown_report.rs— inlinefile.strip_prefix(strip_prefix).unwrap_or(file)(~line 123).All three are byte-identical to
strip_path_prefix.Output-path validate + write (→
validate_output_path/write_output_or_stdout):commands.rs::run_command_report(validate block ~1585, write ~1614).commands.rs::run_command_exemptions(validate ~2158, write ~2194).The new
validate_output_pathemits the same error wording(
--output must be a file path for \`,parent directory of--output does not exist: …
); confirm the write-pathdie_io` verb matchesthe existing message before swapping (keep the message identical).
Acceptance
exemptions.rsandmarkdown_report.rscallstrip_path_prefix; the privatestripfn is removed.run_command_report/run_command_exemptionsuse the shared validate/writehelpers with byte-identical error messages.
Found during #544 review; additive/non-breaking, no milestone.
Resolution
Fixed in
e28cd710(branchfix/issue-545). Pure DRY refactor, nobehavior change.
exemptions.rs: the 6strip(...)call sites now callformat_util::strip_path_prefix; the privatestripfn is removed.markdown_report.rs: the inlinefile.strip_prefix(strip_prefix).unwrap_or(file)inextract_summariesnow callsstrip_path_prefix. The shared helper'sempty-prefix guard yields an identical result for the default empty
prefix.
commands.rs:run_command_reportandrun_command_exemptionsnowuse
validate_output_pathandwrite_output_or_stdout. Error wording(
--output must be a file path for \`,parent directory of--output does not exist: …
) and write verbs (write report to,write exemptions report to`) are byte-identical to the prior inlineblocks.
Validation:
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings, andcargo test --workspace --all-featuresall pass. Existing report/exemptions tests pass unmodified; no
.snap.newdrift.