rust-lang / rust-lang/rust-clippy
Add support for binary function calls in suspicious_operation_groupings lint
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
#6086 introduced suspicious_operation_groupings that made us find a binop issue in Gstreamer. In addition to if statements in #6275 it'd be nice to support binary function call chains like cmp as well, which suffered the same issue:
self.0
.hours
.cmp(&other.0.hours)
.then_with(|| self.0.minutes.cmp(&other.0.hours)) // Should be other.0.minutes
.then_with(|| self.0.seconds.cmp(&other.0.seconds))
.then_with(|| self.0.frames.cmp(&other.0.frames))
The expressions are separated by then_with and closures instead of a simple && binary op so this might be quite a stretch.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the suspicious_operation_groupings implementation introduced by #6086 and compare the if-statement support discussed in #6275. Reproduce the chained cmp and then_with example from this issue, then verify that the lint identifies inconsistent operands across the binary call chain and closure expressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100