MartinThoma / flake8-simplify

❄ A flake8 plugin that helps you to simplify code
MIT License
185 stars 19 forks source link

[New Rule] Duplicate blocks in if/else #192

Open sanxiyn opened 7 months ago

sanxiyn commented 7 months ago

Explanation

Inspired by if_same_then_else rule in Rust Clippy. See https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else. SIM114(#10) is similar, but it only checks if/elif, not if/else.

Example

# Bad
if a:
    b
else:
    b

# Good
b