From 0a1b27fcfa912ec117dc69c9c72facb5d183022f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 11 Jun 2019 11:18:48 +0200 Subject: [PATCH] CI: add clang-format as a tool - update the style guide to require braces around blocks - add a clang-format file that is pretty close to the astyle configuration --- .clang-format | 33 +++++++++++++++++++++++++++++++++ ci/HACKING.md | 12 ++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..1eb0867e1 --- /dev/null +++ b/.clang-format @@ -0,0 +1,33 @@ +--- +BasedOnStyle: WebKit + +AlignAfterOpenBracket: Align +AllowAllParametersOfDeclarationOnNextLine: 'false' +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: 'false' +AllowShortLoopsOnASingleLine: 'false' +AlwaysBreakAfterDefinitionReturnType: All +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: 'false' +BinPackParameters: 'false' +BreakBeforeBraces: Allman +BreakBeforeTernaryOperators: 'true' +BreakConstructorInitializers: BeforeComma +ColumnLimit: 120 +Cpp11BracedListStyle: 'false' +FixNamespaceComments: 'true' +IncludeBlocks: Preserve +IndentWidth: '4' +MaxEmptyLinesToKeep: '2' +NamespaceIndentation: Inner +PointerAlignment: Left +ReflowComments: 'false' +SortIncludes: 'true' +SpaceAfterCStyleCast: 'false' +SpacesBeforeTrailingComments: '2' +SpacesInAngles: 'true' +SpacesInParentheses: 'true' +SpacesInSquareBrackets: 'true' +Standard: Cpp11 + +... diff --git a/ci/HACKING.md b/ci/HACKING.md index f2e6308d1..10d1ac46b 100644 --- a/ci/HACKING.md +++ b/ci/HACKING.md @@ -56,7 +56,7 @@ some PEP8 guidelines. * For pointer and reference variable declarations, put a space before the variable name and no space between the type and the `*` or `&`, e.g. `int* p`. * `for`, `if`, `else`, `while` and similar statements put the braces on the next line, - if the following block is more than one statement. Use no braces for single statements. + if the following block is more than one statement. Always use braces. * Function and class definitions have their braces on separate lines. * A function implementation's return type is on its own line. * `CamelCase.{cpp,h}` style file names. @@ -86,9 +86,13 @@ MyClass::myMethod( QStringList list, const QString& name ) } ``` -You can use the `ci/calamaresstyle` script to run -[astyle](http://astyle.sf.net) on your code and have it formatted the right -way. +You can use `clang-format` (version 7) to have Calamares sources formatted +the right way. There is a `.clang-format` file that specifies the details. +In general: +``` + $ clang-format-7 -i -style=file +``` +` **NOTE:** An .editorconfig file is included to assist with formatting. In order to take advantage of this functionality you will need to acquire the