test(platform-value): improve coverage for pointer, bytes_36, path operations, and diff#3437
Conversation
…erations, and diff Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughComprehensive unit test coverage was added to four modules in the Changes
Estimated Code review effort🎯 3 (Moderate) | ⏱️ ~28 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Review GateCommit:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/rs-platform-value/src/types/bytes_36.rs (1)
531-536: Potential clippy warning:.clone()onCopytype in test.
Bytes36isCopy, so this may triggerclippy::clone_on_copydepending on workspace lint settings.Suggested change (keep test intent + stay clippy-clean)
#[test] + #[allow(clippy::clone_on_copy)] fn clone_is_equal() { let b = Bytes36::new([77u8; 36]); let c = b.clone(); assert_eq!(b, c); }As per coding guidelines, "Follow rustfmt defaults and keep code clippy-clean for Rust modules" and "Ensure Rust code passes clippy linter checks via
cargo clippy --workspace".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/rs-platform-value/src/types/bytes_36.rs` around lines 531 - 536, The test clone_is_equal creates a clone of a Copy type (Bytes36) which can trigger clippy::clone_on_copy; change the test to avoid calling .clone() by using a direct copy instead (e.g., replace the `let c = b.clone();` usage with a copy assignment `let c = b;`) while keeping the same assertions; locate the test function named clone_is_equal and update the creation/assertion around Bytes36::new([77u8; 36]) accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/rs-platform-value/src/inner_value_at_path.rs`:
- Around line 812-844: The tests miss indexed-array path cases and the removal
logic in remove_values_matching_path incorrectly checks bounds and uses unwrap
on array indexing; add unit tests exercising indexed paths (e.g., call
remove_values_matching_path("items[0].key") and an out-of-range index like
"items[99]") to assert correct removal and that out-of-range returns empty
without panicking, and fix the implementation in remove_values_matching_path by
correcting the bound check (use array.len() <= number_index or compare using
number_index >= array.len() appropriately) and replace direct indexing + unwrap
with safe access (array.get(number_index)) and handle None by returning an empty
vec.
In `@packages/rs-platform-value/src/types/bytes_36.rs`:
- Around line 373-379: The test hash_different_values asserts a property that
different values must hash differently, which is not guaranteed; update the test
to assert the guaranteed hashing behavior instead: verify that a value and its
identical clone/hash of itself produce equal hashes (use Bytes36::new,
compute_hash and e.g. a.clone() or a copy) or otherwise remove the
non-guaranteed inequality check so the test only asserts that equal values hash
equally via compute_hash(&a) and compute_hash(&a_clone).
---
Nitpick comments:
In `@packages/rs-platform-value/src/types/bytes_36.rs`:
- Around line 531-536: The test clone_is_equal creates a clone of a Copy type
(Bytes36) which can trigger clippy::clone_on_copy; change the test to avoid
calling .clone() by using a direct copy instead (e.g., replace the `let c =
b.clone();` usage with a copy assignment `let c = b;`) while keeping the same
assertions; locate the test function named clone_is_equal and update the
creation/assertion around Bytes36::new([77u8; 36]) accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3de41e25-e99f-4784-90e1-79db2b42a4a0
📒 Files selected for processing (4)
packages/rs-platform-value/src/inner_value_at_path.rspackages/rs-platform-value/src/patch/diff.rspackages/rs-platform-value/src/pointer.rspackages/rs-platform-value/src/types/bytes_36.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3437 +/- ##
============================================
+ Coverage 80.66% 80.74% +0.08%
============================================
Files 2852 2852
Lines 285371 286153 +782
============================================
+ Hits 230190 231055 +865
+ Misses 55181 55098 -83
🚀 New features to boost your workflow:
|
Summary
Adds 119 tests across 4 files in rs-platform-value covering real logic.
pointer.rstypes/bytes_36.rsinner_value_at_path.rspatch/diff.rsTest plan
cargo test -p platform-value --libpassescargo fmt --allclean🤖 Generated with Claude Code
Summary by CodeRabbit