[cmake-developers] Code style auto-formatting
Brad King
brad.king at kitware.com
Mon May 9 14:17:56 EDT 2016
On 05/09/2016 01:48 PM, Daniel Pfeifer wrote:
> "AllowShortFunctionsOnASingleLine: Inline" is default in the Mozilla
> preset. This line can be removed.
Yes, thanks.
> What is your rationale for "IndentCaseLabels: false"? I find that
> indenting them increases readability when switch statements use
> hanging braces. If the opening "{" is on a separate line, indenting
> the labels does not improve readability that much.
I experimented with it and liked the reduced horizontal space usage,
especially given the column limit. However I see you're right about
this case:
switch (x) {
case 1: {
} break;
default: {
}
}
versus
switch (x) {
case 1: {
} break;
default: {
}
}
We can drop that line.
> What is the rationale for "ColumnLimit: 79"? To make a line fit on old
> school terminals, 80 should be OK. To make a diff or an email response
> fit on old school terminals, two extra spaces are reserved. That leads
> to a column limit of 78. Where does 79 come from?
That has been CMake's limit for a long time. Since we're changing the
style anyway we might as well go with the more common 80 chars that is
default in the Mozilla style.
This brings us to:
---
# This configuration requires clang-format 3.8 or higher.
BasedOnStyle: Mozilla
AlignOperands: false
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterDefinitionReturnType: None
Standard: Cpp03
...
-Brad
More information about the cmake-developers
mailing list