Fix multiline brace placement for clang#3540
Fix multiline brace placement for clang#3540madolson wants to merge 1 commit intovalkey-io:unstablefrom
Conversation
…atements
Change BreakBeforeBraces from Attach to Custom with
AfterControlStatement: MultiLine. This moves the opening brace of
multiline if/for/while/else-if conditions to its own line, improving
readability by visually separating the condition from the body.
Before:
if (foo &&
bar) {
body;
}
After:
if (foo &&
bar)
{
body;
}
This matches the style used by Redis for multiline control statements.
All source files reformatted with clang-format-18 using the updated
config (51 files, 324 instances).
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #3540 +/- ##
============================================
- Coverage 76.41% 76.41% -0.01%
============================================
Files 159 159
Lines 79927 79925 -2
============================================
- Hits 61078 61072 -6
- Misses 18849 18853 +4
🚀 New features to boost your workflow:
|
|
I prefer that we don't merge this change. We have already taken the hit and removed that style. Changing back now two years later will cause merge conflicts again. Arguably, placing the brace on its own line or not depending on the condition in the if/while is also a bit unintuitive. If you're not aware of the rule, you'd just think that it's random and that both styles are accepted (brace on same line or on its own line). |
|
We can backport it to avoid the merge conflicts, everything will be consistent across branches. I don't know what to say about it being unintuitive. The alternative of forcing indentation is also weird. It was the style consistently used in redis (and still is). |
We have lots of development forks and work going on now. Forkless, key blocking, sync replication, raft cluster, ... lot's of merge conflicts to handle.
We have this style with the opening brace always at the end of the line (subjectively weird or not) consistency used in Valkey for two years... and you think we should copy Redis? |
So when we merged the original clang format, we merged something I think a few of us had an issue with which was indentation on multi-line control statements made it hard to see when if ended and when the code began, example:
listTypeReleaseIterator is not part of the conditional, but it looks like it is. The current code formatter forces this. Without a column limit, there is not way to force the multi-line, but the provided configuration makes it "allowed".
Also, the original Redis style did this.