Repository navigation
refactor(fgumi): deduplicate core lib modules and remove redundant state - #151
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #151 +/- ##
==========================================
+ Coverage 83.61% 83.65% +0.03%
==========================================
Files 126 126
Lines 51510 51248 -262
==========================================
- Hits 43069 42869 -200
+ Misses 8441 8379 -62 ☔ 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 (5)
📝 WalkthroughWalkthroughThis pull request refactors multiple modules to delegate operations to external libraries and consolidate internal helper logic. Changes include: replacing a local reference-length calculation with an external API call in bam_io.rs, centralizing sibling-file lookup logic via a new private helper in reference.rs, renaming base_seq to next_seq for sequence tracking in reorder_buffer.rs, replacing manual tag reversal with external helper functions in tag_reversal.rs, and converting four public template methods from returning vectors to slices in template.rs. 🚥 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 (2)
src/lib/tag_reversal.rs (1)
174-190: Userstestfor this parameterized case matrix.Lines 176-189 are parameterized through a manual case loop; convert this to
rstestcases to match project test conventions.As per coding guidelines,
**/*.rs: Use rstest for parameterized tests.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/tag_reversal.rs` around lines 174 - 190, The test test_reverse_buf_value_all_array_types uses a manual loop over test_cases; convert it to an rstest-parameterized test by replacing the function with a #[rstest] test that declares parameters (e.g., input, expected) and lists each tuple as a case(...) for the different array types, then call fgumi_sam::reverse_buf_value(&input) and assert_eq!(reversed, expected) inside the test; also add the necessary use rstest::rstest import and remove the Vec and for loop so each case is reported separately by the test runner.src/lib/reorder_buffer.rs (1)
288-292: Consider renaming the test helper for clarity.Line 290 still uses
set_base_seq, but Line 291 mutatesnext_seq. Renaming this helper would better match the new internal model.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/reorder_buffer.rs` around lines 288 - 292, The test helper set_base_seq in reorder_buffer.rs is misleading because it mutates the internal field next_seq; rename the function to reflect its purpose (e.g., set_next_seq or set_sequence_cursor) and update all references in tests to the new name so the helper accurately describes that it sets the next_seq field used by the reorder buffer.
🤖 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/lib/template.rs`:
- Around line 341-345: The records_in_range method currently only checks end <=
self.records.len() before slicing, but must also guard that start <= end and
start <= self.records.len(); update records_in_range (function name) to validate
both that start <= end and that start < = self.records.len() (and end <=
self.records.len()) and return an empty slice when the range is invalid so the
slice &self.records[start..end] cannot panic.
---
Nitpick comments:
In `@src/lib/reorder_buffer.rs`:
- Around line 288-292: The test helper set_base_seq in reorder_buffer.rs is
misleading because it mutates the internal field next_seq; rename the function
to reflect its purpose (e.g., set_next_seq or set_sequence_cursor) and update
all references in tests to the new name so the helper accurately describes that
it sets the next_seq field used by the reorder buffer.
In `@src/lib/tag_reversal.rs`:
- Around line 174-190: The test test_reverse_buf_value_all_array_types uses a
manual loop over test_cases; convert it to an rstest-parameterized test by
replacing the function with a #[rstest] test that declares parameters (e.g.,
input, expected) and lists each tuple as a case(...) for the different array
types, then call fgumi_sam::reverse_buf_value(&input) and assert_eq!(reversed,
expected) inside the test; also add the necessary use rstest::rstest import and
remove the Vec and for loop so each case is reported separately by the test
runner.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/lib/bam_io.rssrc/lib/reference.rssrc/lib/reorder_buffer.rssrc/lib/tag_reversal.rssrc/lib/template.rs
Replace duplicated reference-length calculation in bam_io with fgumi_raw_bam::reference_length_from_raw_bam. Replace hand-rolled array/string reversal in tag_reversal with fgumi_sam::reverse_buf_value and revcomp_buf_value. Extract shared find_sibling_file helper for find_fai_path/find_dict_path in reference.rs. Unify four identical template accessor methods via records_in_range helper returning slices instead of Vec. Remove redundant base_seq field from ReorderBuffer.
635f60f to
78cee20
Compare
Summary
calculate_reference_lengthinbam_io.rswithfgumi_raw_bam::reference_length_from_raw_bam(-43 lines)tag_reversal.rswithfgumi_sam::reverse_buf_valueandrevcomp_buf_value(-64 lines)find_sibling_filehelper forfind_fai_path/find_dict_pathinreference.rs(-16 lines)records_in_rangehelper, returning&[RecordBuf]instead ofVec<&RecordBuf>(-40 lines)base_seqfield fromReorderBufferthat was always equal tonext_seq(-12 lines)Test plan
cargo ci-test)cargo ci-fmt)cargo ci-lint)