Aaronontheweb / EvilRoslynAnalyzers

Has your boss gone insane and banned LINQ at work? Why stop there - use this Roslyn Analyzer to ban extension methods altogether!
https://www.reddit.com/r/dotnet/comments/1c4hz1z/linq_forbidden/
Apache License 2.0
31 stars 2 forks source link

Feature idea: Every `if` must have `else` #16

Open TenCoKaciStromy opened 4 months ago

TenCoKaciStromy commented 4 months ago

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 */ }
Mrxx99 commented 4 months ago

Something similar exists for real when using else if in the popular sonar scanner: https://rules.sonarsource.com/csharp/RSPEC-126/?search=Else

TenCoKaciStromy commented 4 months ago

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 😭

flobernd commented 4 months ago

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.