From 9aff065b467a92014a602dca23b40182c62d9ab8 Mon Sep 17 00:00:00 2001 From: Lazlo Westerhof Date: Fri, 8 Mar 2024 15:25:23 +0100 Subject: [PATCH] YDA-5623: add clang-format workflow --- .clang-format | 203 ++++++++++++++++++ .../workflows/linter-irods-clang-format.yml | 18 ++ 2 files changed, 221 insertions(+) create mode 100644 .clang-format create mode 100644 .github/workflows/linter-irods-clang-format.yml diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f67c264 --- /dev/null +++ b/.clang-format @@ -0,0 +1,203 @@ +--- +DisableFormat: false + +Language: Cpp +Standard: c++20 + +ColumnLimit: 120 +UseCRLF: false + +#UseTab: AlignWithSpaces +UseTab: Never +TabWidth: 4 +IndentWidth: 4 +ConstructorInitializerIndentWidth: 4 + +IndentPPDirectives: AfterHash +PPIndentWidth: 2 + +IndentAccessModifiers: false +AccessModifierOffset: -2 + +AlignAfterOpenBracket: Align +#AlignAfterOpenBracket: BlockIndent +AlignArrayOfStructures: None +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: Consecutive +AlignConsecutiveDeclarations: None +AlignConsecutiveMacros: AcrossEmptyLinesAndComments +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: false + +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false + +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false + +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentRequires: true +#IndentRequiresClause: true +IndentWrappedFunctionNames: false +LambdaBodyIndentation: Signature +NamespaceIndentation: All + +AlwaysBreakAfterReturnType: None +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes + +BinPackArguments: false +BinPackParameters: false + +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: true +BreakBeforeInheritanceComma: true +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeComma +BreakInheritanceList: BeforeComma +BreakStringLiterals: true +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: true + AfterControlStatement: MultiLine + AfterEnum: true + AfterExternBlock: false + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: true + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyNamespace: true + SplitEmptyRecord: true + +#InsertBraces: false +#RemoveBracesLLVM: false + +DeriveLineEnding: true +DerivePointerAlignment: false +ExperimentalAutoDetectBinPacking: false + +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpacesInLineCommentPrefix: + Minimum: 0 + Maximum: -1 + +BitFieldColonSpacing: Both +Cpp11BracedListStyle: true + +FixNamespaceComments: true +ShortNamespaceLines: 0 + +SortIncludes: Never +SortUsingDeclarations: true + +PointerAlignment: Left +ReferenceAlignment: Pointer + +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 1 +#SeparateDefinitionBlocks: Always + +AttributeMacros: + - __capability + - __extension__ + - __const__ + - __volatile__ + - __signed__ + - __inline__ + - BOOST_RESTRICT + - BOOST_FORCEINLINE + - BOOST_NOINLINE + - BOOST_NORETURN + - BOOST_ATTRIBUTE_UNUSED + - BOOST_ATTRIBUTE_NODISCARD + - BOOST_ATTRIBUTE_NO_UNIQUE_ADDRESS + - BOOST_MAY_ALIAS + - BOOST_NO_MAY_ALIAS + - BOOST_SYMBOL_VISIBLE + - BOOST_SYMBOL_EXPORT + - BOOST_SYMBOL_IMPORT + - BOOST_INLINE_VARIABLE + - BOOST_INLINE_CONSTEXPR + - BOOST_NOEXCEPT_OR_NOTHROW + - BOOST_FINAL + - BOOST_OVERRIDE +ForEachMacros: + - foreach + - BOOST_FOREACH + - BOOST_REVERSE_FOREACH +IfMacros: + - CATCH_CHECKED_IF + - CATCH_CHECKED_ELSE + - CHECKED_IF + - CHECKED_ELSE + - BOOST_IF_CONSTEXPR +StatementMacros: + - BOOST_PRAGMA_MESSAGE + - BOOST_HEADER_DEPRECATED +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_STRINGIZE + - BOOST_PP_STRINGIZE + - BOOST_PP_WSTRINGIZE + - CMAKE_STRINGIFY + - CMAKE_TOSTRING + +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 0 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +#PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 200 + +CommentPragmas: '^ (IWYU pragma:|(NOLINT(NEXTLINE|BEGIN|END)?)|clang-format)' +CompactNamespaces: false +IncludeBlocks: Preserve +InsertTrailingCommas: None +ReflowComments: true +#RequiresClausePosition: OwnLine diff --git a/.github/workflows/linter-irods-clang-format.yml b/.github/workflows/linter-irods-clang-format.yml new file mode 100644 index 0000000..fb5ef68 --- /dev/null +++ b/.github/workflows/linter-irods-clang-format.yml @@ -0,0 +1,18 @@ +name: linter-irods-clang-format +on: [push, pull_request] +defaults: + run: + shell: bash +jobs: + clang-format: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + + - name: Install Clang Format + run: | + sudo apt-get install -y clang-format + + - name: Run Clang-Format + run: | + clang-format -n src/*