Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
no-else-return : else if #3015
With no-else-return activated:
The final else is considered a violation -- which makes technical sense given the implementation, but seems contrary to the intent of the rule (to eliminate superfluous else statements). The final else block is meaningful here despite the preceding "returning" if because it's also still an alternative of the first case, which did not return. Handling that distinction might be more trouble than it's worth, since grammatically, "else if" is not a concept, it's just "else statement" where the statement happens to be an "if", but I figured I'd ask just in case it's a viable refinement after all.
For anyone else running into this who'd like to keep the rule on -- this is how the no-else-return rule would prefer to see that logic expressed:
It's not that bad, just a bit unnatural when compared to the standard else-if pattern.