From ad163485c0648cfdf9094b5fbfb77a4965a6af4a Mon Sep 17 00:00:00 2001 From: Tomasz Wezyk Date: Tue, 16 Feb 2021 10:41:19 +0100 Subject: [PATCH] clang format checks --- .clang-format | 70 ++++++++++++------------ .github/workflows/clang-format-check.yml | 10 ++++ 2 files changed, 45 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/clang-format-check.yml diff --git a/.clang-format b/.clang-format index bd1caad1..81ba511e 100644 --- a/.clang-format +++ b/.clang-format @@ -1,17 +1,16 @@ --- Language: Cpp -# BasedOnStyle: LLVM AccessModifierOffset: -4 -AlignAfterOpenBracket: DontAlign +AlignAfterOpenBracket: Align AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Right +AlignEscapedNewlines: Left AlignOperands: true AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: Empty +AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None @@ -20,62 +19,56 @@ AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: true BinPackArguments: true BinPackParameters: true -BraceWrapping: +BraceWrapping: AfterClass: true AfterControlStatement: true AfterEnum: true AfterFunction: true - AfterNamespace: false + AfterNamespace: true AfterObjCDeclaration: true AfterStruct: true AfterUnion: true + AfterExternBlock: true BeforeCatch: true BeforeElse: true IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true BreakBeforeBinaryOperators: None BreakBeforeBraces: Custom BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: true -BreakConstructorInitializers: BeforeColon -BreakAfterJavaFieldAnnotations: false +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: AfterColon +BreakAfterJavaFieldAnnotations: true BreakStringLiterals: true -ColumnLimit: 140 +ColumnLimit: 180 CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: +FixNamespaceComments: false +ForEachMacros: - foreach - Q_FOREACH - BOOST_FOREACH -IncludeCategories: - - Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Priority: 2 - - Regex: '^(<|"(gtest|gmock|isl|json)/)' - Priority: 3 - - Regex: '.*' - Priority: 1 -IncludeIsMainRegex: '(Test)?$' -IndentCaseLabels: false +IndentCaseLabels: true +IndentPPDirectives: None IndentWidth: 4 IndentWrappedFunctionNames: false JavaScriptQuotes: Leave JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true +KeepEmptyLinesAtTheStartOfBlocks: false MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None +NamespaceIndentation: All ObjCBlockIndentWidth: 2 ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: true @@ -87,6 +80,11 @@ PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Right +RawStringFormats: + - Language: TextProto + Delimiters: + - pb + BasedOnStyle: google ReflowComments: true SortIncludes: false SortUsingDeclarations: true @@ -97,12 +95,14 @@ SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: false -SpacesInContainerLiterals: true +SpacesInContainerLiterals: false SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Cpp11 -TabWidth: 8 +TabWidth: 4 UseTab: Never -... - +--- +# Don't format Objective C files. This is required so that clang-format does not exit with an error code. +Language: ObjC +DisableFormat: true \ No newline at end of file diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml new file mode 100644 index 00000000..dc1f7d24 --- /dev/null +++ b/.github/workflows/clang-format-check.yml @@ -0,0 +1,10 @@ +name: clang-format Check +on: [push] +jobs: + formatting-check: + name: Formatting Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run clang-format style check for C programs. + uses: jidicula/clang-format-action@master \ No newline at end of file