-
Notifications
You must be signed in to change notification settings - Fork 14
Make remaining bytes validation conditional on strict mode #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe pull request modifies error validation logic in 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/atom.rs`:
- Around line 66-69: Collapse the nested conditional checks into a single if
expression to satisfy clippy's collapsible_if lint: replace the outer
cfg!(feature = "strict") || cfg!(test) guard and the inner body.has_remaining()
check with one combined condition that tests both (e.g., if (cfg!(feature =
"strict") || cfg!(test)) && body.has_remaining()) and return
Err(Error::UnderDecode(T::KIND)) when true; apply the same change to the second
occurrence that currently returns Err(Error::UnderDecode(T::KIND)) when
body.has_remaining() under the cfg guard.
| if cfg!(feature = "strict") || cfg!(test) { | ||
| if body.has_remaining() { | ||
| return Err(Error::UnderDecode(T::KIND)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# First, locate the file and check its size
fd -t f "atom.rs" | head -20Repository: kixelated/mp4-atom
Length of output: 91
🏁 Script executed:
# Read the relevant sections of src/atom.rs
cat -n src/atom.rs | sed -n '60,75p'Repository: kixelated/mp4-atom
Length of output: 642
🏁 Script executed:
# Also check the second location
cat -n src/atom.rs | sed -n '140,155p'Repository: kixelated/mp4-atom
Length of output: 678
🏁 Script executed:
# Check for other potential clippy issues in src/atom.rs
rg "if.*{" src/atom.rs -A 2 | head -50Repository: kixelated/mp4-atom
Length of output: 135
🏁 Script executed:
# Search for nested if patterns more carefully
rg "if cfg!" src/atom.rs -A 2Repository: kixelated/mp4-atom
Length of output: 358
🏁 Script executed:
# Also check the full context around both locations to ensure no other issues
cat -n src/atom.rs | sed -n '50,80p'Repository: kixelated/mp4-atom
Length of output: 1157
Collapse the nested if blocks to unblock clippy.
Clippy flags these as collapsible_if, and with -D warnings this fails CI. Collapsing the condition resolves the lint at both sites.
🛠️ Proposed fix
- if cfg!(feature = "strict") || cfg!(test) {
- if body.has_remaining() {
- return Err(Error::UnderDecode(T::KIND));
- }
- }
+ if (cfg!(feature = "strict") || cfg!(test)) && body.has_remaining() {
+ return Err(Error::UnderDecode(T::KIND));
+ }- if cfg!(feature = "strict") || cfg!(test) {
- if body.has_remaining() {
- return Err(Error::UnderDecode(T::KIND));
- }
- }
+ if (cfg!(feature = "strict") || cfg!(test)) && body.has_remaining() {
+ return Err(Error::UnderDecode(T::KIND));
+ }Also applies to: 147-150
🧰 Tools
🪛 GitHub Actions: PR
[error] 66-66: Clippy: this if statement can be collapsed.
🪛 GitHub Check: build
[failure] 66-66:
this if statement can be collapsed
🤖 Prompt for AI Agents
In `@src/atom.rs` around lines 66 - 69, Collapse the nested conditional checks
into a single if expression to satisfy clippy's collapsible_if lint: replace the
outer cfg!(feature = "strict") || cfg!(test) guard and the inner
body.has_remaining() check with one combined condition that tests both (e.g., if
(cfg!(feature = "strict") || cfg!(test)) && body.has_remaining()) and return
Err(Error::UnderDecode(T::KIND)) when true; apply the same change to the second
occurrence that currently returns Err(Error::UnderDecode(T::KIND)) when
body.has_remaining() under the cfg guard.
|
Did this behaviour get mandated in ISOBMFF? I recall some discussion, but not the outcome. |
No description provided.