EvilRoslynAnalyzers
EvilRoslynAnalyzers copied to clipboard
Feature idea: Every `if` must have `else`
Why? It's a protection against 10x ADHD developers who jumps from one project to another and stops coding in the middle of method and forgots the else
part. (Instead of properly reporting every line of code to company timesheets and follow waterfall roadmap.)
Wrong:
if (something) { ... }
Right:
if (something) { ... }
else { /* didn't forgot about else branch */ }
Something similar exists for real when using else if in the popular sonar scanner: https://rules.sonarsource.com/csharp/RSPEC-126/?search=Else
Something similar exists for real when using else if in the popular sonar scanner: https://rules.sonarsource.com/csharp/RSPEC-126/?search=Else
That's horrible 😭
The Sonar rule is actually not that horrible 😅 It's the equivalent to an exhaustive pattern match, which is enforced in many languages to avoid a lot of logic flaws at compile time.