rust-lang / rust-lang/rust-clippy
Duplicated sub-conditions in boolean expression lint
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
In this code below the test contains two repeated expressions. This could be a mistake (a bug) so I think it's a good idea for Clippy to spot it with a lint similar to "ifs_same_cond".
Lint Name
redundant_sub_cond
Category
suspicious
Advantage
No response
Drawbacks
No response
Example
fn test1(s: &str) -> bool {
if s.is_empty() || s.is_empty() {
return false;
}
true
}
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 by comparing the proposed redundant_sub_cond lint with the existing ifs_same_cond lint mentioned in the issue, then locate Clippy's lint implementation and test conventions. Add coverage for the repeated s.is_empty() expressions shown in the example, with completion demonstrated by the lint detecting that duplicated sub-condition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100