refactor(diffguard-core): split run_check into SRP submodules#1614
refactor(diffguard-core): split run_check into SRP submodules#1614EffortlessSteven wants to merge 1 commit into
Conversation
The 165-line run_check function in check.rs did seven distinct things in one body. Promote check.rs to a check/ module directory and extract each concern into its own submodule: - diff_prep — parse, path-filter, allowed-line filter, dedup - rule_filter — tag-based rule selection (only/enable/disable) - false_positive — fingerprint filtering + per-rule analytics tallies - verdict — status + exit code from counts - annotations — GitHub Actions annotation rendering - rule_hits — domain stats → core stats, with FP adjustments - path_filter — glob compilation + PathFilterError run_check now reads as a 7-step pipeline. The public surface (CheckPlan, CheckRun, RuleHitStat, PathFilterError, run_check) is unchanged; sensor_api, the CLI, and the LSP keep working without edits. Snapshot files relocated to check/snapshots/ to match insta's source-relative discovery; their bodies are byte-identical. Tests co-locate with the code they cover: tag-filter tests under rule_filter, exit-code tests under verdict, the annotations proptest under annotations. The run_check-level integration tests and snapshot tests stay in check/mod.rs so snapshot file names remain stable.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (8)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
run_checkindiffguard-core/src/check.rswas a 165-line function doing seven distinct things: diff parsing & filtering, rule tag filtering, evaluation dispatch, false-positive filtering, verdict computation, receipt assembly, and output rendering. Promotecheck.rsto acheck/module directory and extract each concern into its own SRP submodule:diff_preprule_filteronly_tags/enable_tags/disable_tags)false_positiveverdictannotationsrule_hitspath_filterPathFilterErrorrun_checknow reads as a 7-step pipeline. The orchestrator went from ~165 lines of intermixed logic to ~85 lines that call each step by name.Public API
Unchanged.
CheckPlan,CheckRun,RuleHitStat,PathFilterError, andrun_checkare still re-exported fromdiffguard_coreat the same paths.sensor_api.rscontinues to importcrate::check::{CheckPlan, run_check}; the CLI and LSP need no edits.Snapshots
diffguard_core__check__tests__snapshot_*.snapfiles moved fromsrc/snapshots/tosrc/check/snapshots/to matchinsta's source-relative discovery (file bodies byte-identical, onlysource:header path updated).Tests
rule_filterverdict(plus three new tests coveringcompute_verdict_statusdirectly)annotationsrun_check-level integration tests and the two existing snapshot tests stay incheck/mod.rsso snapshot file names remain stableTest plan
cargo build -p diffguard-core— cleancargo test -p diffguard-core— 144 lib + all integration tests pass (3 added verdict tests)cargo test --workspace— all green except 26 pre-existingdiffguard --binfailures unrelated to this change (sandbox can't rungit commit; reproduces onmainworktree)cargo clippy --workspace --all-targets -- -D warnings— cleancargo fmt --check— cleanGenerated by Claude Code