-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 Request: Vertical Whitespace between Cases #1517
Comments
I think this would be useful, but I'm not sure if it should be a default rule. |
I personally prefer a line before the first case as well, for consistency, so it would be nice to have that option. |
Okay, this sounds to me like the rule would be merged, if it had enough configuration options. Sure, I'll try to add them, too then. Let's see when I will have the time to tackle this. Probably end of this week ... |
Hey guys, not entirely related but very close, so I was thinking if this could be part of this rule as a configuration? I can open a new issue if you prefer. The idea is not to have vertical whitespace after a // ❌not acceptable
switch x {
case 0..<5:
// some code
case 5..<10:
// some code
default:
// some code
}
// ✅ acceptable
switch x {
case 0..<5:
// some code
case 5..<10:
// some code
default:
// some code
} |
@gobetti I like the idea, though I think it should be part of a new rule which could be named something like |
This is a rule request. I'm willing to implement this myself and send a PR, but before doing that I'd like to know if the rule is wanted or not. To explain the desired rule, I'd like to first post the custom rule we are already using in our projects:
I felt like this rule might be useful for other projects as well, which is why I'm posting it. What do you think about it? For us it helps a lot to prevent common issues and enforce a shared style.
Rationale
We had this discussion a few times, the common ground we were all happy with is this: When using switch-case there should be a newline before a new case begins except for the last case, because there's already a closing parentheses and indentation there as visual clues.
A few examples:
The text was updated successfully, but these errors were encountered: