diff --git a/.clang-format.optional b/.clang-format similarity index 55% rename from .clang-format.optional rename to .clang-format index 9984b76d..83d40c72 100644 --- a/.clang-format.optional +++ b/.clang-format @@ -1,16 +1,26 @@ --- -BasedOnStyle: Google -Language: Cpp -Standard: Cpp03 +# Indentation for all files +ColumnLimit: 120 +IndentWidth: 4 TabWidth: 4 UseTab: Never -ColumnLimit: 120 -NamespaceIndentation: All + +# C++ Options +Language: Cpp +Standard: c++17 + +BasedOnStyle: Google + +IncludeBlocks: Preserve AccessModifierOffset: -4 ContinuationIndentWidth: 4 -IndentWidth: 4 +# Constructor initializers better formatted in presence of preprocessor conditions (see image.cpp) +BreakConstructorInitializers: AfterColon +AllowAllConstructorInitializersOnNextLine: true + +# break braces for most of the cases (except conditionals and loops) BreakBeforeBraces: Custom BraceWrapping: AfterStruct: true @@ -20,11 +30,12 @@ BraceWrapping: AfterEnum: true AfterNamespace: true +# Do not allow SingleLine statements (to improve coverage statistics) AllowShortFunctionsOnASingleLine: None AllowShortBlocksOnASingleLine: false AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false -IncludeBlocks: Preserve +Cpp11BracedListStyle: true ... diff --git a/.github/workflows/on_push_clang_format.yml b/.github/workflows/on_push_clang_format.yml new file mode 100644 index 00000000..33bed1be --- /dev/null +++ b/.github/workflows/on_push_clang_format.yml @@ -0,0 +1,14 @@ +name: Clang Format Checker +on: [push] +jobs: + clang-format-checking: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: DoozyX/clang-format-lint-action@v0.13 + with: + source: '.' + exclude: './xmpsdk ./contrib' + extensions: 'c,h,cpp,hpp' + clangFormatVersion: 12 + style: file