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
Curly: multi, but with balanced if-else statements #2390
Comments
We're getting a bit into fuzzy areas here. I think what you're asking for is that if one branch of the if statement has multiple statements then all branches must use curlies, is that correct? I'd call this "multi a consistent". |
Yes, that's correct. |
Interesting option, I'd like to use it. Working on it. |
I was gonna propose this actually. We need this at work too :) 👍 |
New: add "consistent" option to the "curly" rule (refs #2390)
FYI: With non-allman style braces, I agree. However, with allman style braces, inconsistent use of braces looks quite natural (to me and my colleagues at least): if (foo)
{
doSomething();
doSomethingElse();
}
else
doBar(); |
I came here because I ran into the problem at #2366, and it's awesome to see it was just fixed yesterday! I had two other concerns related to brace style as well, both of which are feature requests rather than bug reports.
The first I discovered was already detailed at #1806.
The other I didn't find described yet. I'm curious whether a style option extending 'multi' for curly might be considered, for handling if/else blocks nicely. In my experience those of us who favor multi will nonetheless wish to balance if/else blocks when one or the other is multi-statement. That is, if either 'if' or 'else' is a multi-statement block, the other should use braces as well, or else you end up with rather awkward results.
So the legal forms would be, as with multi:
and of course:
but also, this, which is considered an error when using 'multi':
instead of the form which is currently considered valid (and which I've rarely seen used in practice, for reasons that seem apparent):
The text was updated successfully, but these errors were encountered: