-
-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule proposal: switch-case-limits #2439
Comments
I agree that If they're a list of 15 case/return lines line in your example I think it's fine. Many cases are usually unreadable when each case has 30+ lines each. At that point the native |
I also don't really see the problem with large switches. I do think the first example with the single case could be its own rule though. |
You can use the rule |
I’m using
That’s a good point, the
Should it be still configurable what the threshold of cases should be or just hardcoded to one (e.g. |
Description
A rule that enforces the min or max amount of cases required per switch statement. E.g. a switch statement with just one case or two would be better expressed with
if-else
. At the same time a switch statement with too many cases might be better refactored to a lookup table.Fail
Pass
Proposed rule name
switch-case-limits
Additional Info
No response
The text was updated successfully, but these errors were encountered: