Repository navigation
refactor(commands): extract generic verify helper and deduplicate test code - #152
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #152 +/- ##
==========================================
+ Coverage 83.61% 83.74% +0.13%
==========================================
Files 126 126
Lines 51510 51361 -149
==========================================
- Hits 43069 43012 -57
+ Misses 8441 8349 -92 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Warning Rate limit exceeded
⌛ 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. 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis pull request refactors verification and test utilities. In 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/commands/zipper.rs (1)
935-948: Consider usingrecord_bufs()iterator for simplicity.Other test modules (codec.rs, clip.rs) use a more concise pattern:
let records: Vec<_> = reader.record_bufs(&header).collect::<std::io::Result<Vec<_>>>()?;Also, four test modules now have near-identical
read_bam_recordshelpers. A shared test utility could reduce duplication.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/commands/zipper.rs` around lines 935 - 948, The read_bam_records function currently manually loops over reader.read_record_buf to collect RecordBufs; replace this with the noodles::bam reader.record_bufs(&header) iterator and collect into a Result<Vec<RecordBuf>> (e.g., reader.record_bufs(&header).collect::<std::io::Result<Vec<_>>>()?), and update error handling accordingly in the read_bam_records function; additionally, move this helper into a shared test utility (used by codec.rs, clip.rs and other tests) to eliminate near-duplicate implementations so tests call the common read_bam_records helper instead of duplicating the logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/commands/zipper.rs`:
- Around line 934-949: The doc comment block that describes run_zipper is now
attached to the helper read_bam_records; move the read_bam_records function so
it appears after the run_zipper function (or alternatively move/restore the
run_zipper doc comment immediately above run_zipper) so the documentation
applies to run_zipper, ensuring you update the order of the functions
(run_zipper and read_bam_records) and keep the read_bam_records signature fn
read_bam_records(path: &std::path::Path) -> Result<Vec<RecordBuf>> unchanged.
---
Nitpick comments:
In `@src/commands/zipper.rs`:
- Around line 935-948: The read_bam_records function currently manually loops
over reader.read_record_buf to collect RecordBufs; replace this with the
noodles::bam reader.record_bufs(&header) iterator and collect into a
Result<Vec<RecordBuf>> (e.g.,
reader.record_bufs(&header).collect::<std::io::Result<Vec<_>>>()?), and update
error handling accordingly in the read_bam_records function; additionally, move
this helper into a shared test utility (used by codec.rs, clip.rs and other
tests) to eliminate near-duplicate implementations so tests call the common
read_bam_records helper instead of duplicating the logic.
5c69f15 to
e63c8a4
Compare
…t code Extract verify_sort_order generic function in sort.rs to replace three near-identical verification branches for coordinate, queryname, and template-coordinate sort orders. Use fgumi_raw_bam::read_name instead of hand-rolled byte offset arithmetic. Extract read_bam_records test helper in zipper.rs to deduplicate BAM reading boilerplate across three test functions.
e63c8a4 to
8df6675
Compare
Summary
verify_sort_ordergeneric function insort.rsreplacing 3 near-identical verification branches (-60 lines)fgumi_raw_bam::read_nameinstead of hand-rolled byte offset arithmeticread_bam_recordstest helper inzipper.rsto deduplicate BAM reading boilerplate across 3 test functionsTest plan
cargo ci-test)cargo ci-fmt)cargo ci-lint)