new rule - useless if statement
Open
rule
- Dominant language
- Rust
- Stars
- 49.6k
- Forks
- 2.4k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 458
Description
ruff should be able to detect if the code on both sides of an if statement are identical, and report it as unnecessary
```py
if 1: # error: both sides of the if statement are the same
print(1)
else:
print(1)
asdf = 1 if bool() else 1 # error: both sides of the if expression are the same
```
Contributor guide
Research direction
No file or test is named in the issue. Start by locating Ruff's existing rules and tests for redundant branches or conditional expressions, then use both provided Python examples as regression cases; done means identical if branches and conditional-expression arms are reported as unnecessary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100