Verified Commit 9ab22dbc authored by Thomas Haller's avatar Thomas Haller
Browse files

CONTRIBUTING: clarify on the use/lack of curly braces around blocks

This is the style we have ever since. Spell it out. With the difference
that now single line statements may have braces.

Recently we were already sloppy about allowing curly braces for single line
statements. Maybe there was a point in that. Imagine you start with:

    if (condition)
        call(some, parameter);

Afterwards you change the code so that the line becomes too long and
clang-format wraps the line (requiring you to add braces):

    if (condition) {
        call(some,
             call_another_function(hey));
    }

The problem now is that this diff is larger than it would have been, if
you added curly braces from the start. Also, it means you have to go
back and forth to add/remove these braces, as clang-format reformats the
code.

Also, if you have if-else-if blocks, then mixing multi line statements
with single line statements is also cumbersome, because when something
needs to change, the diff is may be larger (and the change more
cumbersome).

So it might be convenient to just always add the braces, and the
documented style now allows for that.
parent d5f917e7
Pipeline #481391 canceled with stages