diff --git a/.clang-format b/.clang-format index 7bdfb4f2..0ba7d384 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,7 @@ --- Language: Cpp # BasedOnStyle: LLVM -AccessModifierOffset: -2 +AccessModifierOffset: -4 AlignAfterOpenBracket: BlockIndent AlignArrayOfStructures: None AlignConsecutiveAssignments: @@ -28,24 +28,17 @@ AlignConsecutiveMacros: AcrossComments: false AlignCompound: false PadOperators: false -AlignConsecutiveShortCaseStatements: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCaseColons: false AlignEscapedNewlines: Right AlignOperands: Align -AlignTrailingComments: - Kind: Leave - OverEmptyLines: 0 +AlignTrailingComments: false AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: true AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false -AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: Never AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None @@ -55,18 +48,17 @@ AttributeMacros: - __capability BinPackArguments: true BinPackParameters: true -BitFieldColonSpacing: Both BraceWrapping: AfterCaseLabel: true AfterClass: true AfterControlStatement: Always AfterEnum: false - AfterExternBlock: false AfterFunction: true AfterNamespace: false AfterObjCDeclaration: false AfterStruct: false AfterUnion: false + AfterExternBlock: false BeforeCatch: true BeforeElse: true BeforeLambdaBody: false @@ -75,29 +67,34 @@ BraceWrapping: SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true -BreakAfterAttributes: Never -BreakAfterJavaFieldAnnotations: false -BreakArrays: true BreakBeforeBinaryOperators: None BreakBeforeConceptDeclarations: Always #BreakBeforeBraces: Allman BreakBeforeBraces: Custom -BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: AfterColon -BreakInheritanceList: BeforeColon +BreakAfterJavaFieldAnnotations: false BreakStringLiterals: false ColumnLimit: 180 CommentPragmas: '^ IWYU pragma:' +QualifierAlignment: Leave CompactNamespaces: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true +DeriveLineEnding: true DerivePointerAlignment: false DisableFormat: false EmptyLineAfterAccessModifier: Never EmptyLineBeforeAccessModifier: LogicalBlock ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: Never +BasedOnStyle: '' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +AllowAllConstructorInitializersOnNextLine: true FixNamespaceComments: true ForEachMacros: - foreach @@ -122,30 +119,20 @@ IncludeCategories: IncludeIsMainRegex: '(Test)?$' IncludeIsMainSourceRegex: '' IndentAccessModifiers: false -IndentCaseBlocks: false IndentCaseLabels: false -IndentExternBlock: AfterExternBlock +IndentCaseBlocks: false IndentGotoLabels: true IndentPPDirectives: None +IndentExternBlock: AfterExternBlock IndentRequiresClause: true IndentWidth: 4 IndentWrappedFunctionNames: false InsertBraces: false -InsertNewlineAtEOF: false InsertTrailingCommas: None -IntegerLiteralSeparator: - Binary: 0 - BinaryMinDigits: 0 - Decimal: 0 - DecimalMinDigits: 0 - Hex: 0 - HexMinDigits: 0 JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: true -KeepEmptyLinesAtEOF: false LambdaBodyIndentation: Signature -LineEnding: DeriveLF MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 2 @@ -155,7 +142,6 @@ ObjCBlockIndentWidth: 2 ObjCBreakBeforeNestedBlockParam: true ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: true -PackConstructorInitializers: Never PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 @@ -164,33 +150,27 @@ PenaltyBreakOpenParenthesis: 0 PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 -PenaltyIndentedWhitespace: 0 PenaltyReturnTypeOnItsOwnLine: 60 +PenaltyIndentedWhitespace: 0 PointerAlignment: Right PPIndentWidth: -1 -QualifierAlignment: Leave ReferenceAlignment: Pointer ReflowComments: false RemoveBracesLLVM: false -RemoveParentheses: Leave -RemoveSemicolon: false RequiresClausePosition: OwnLine -RequiresExpressionIndentation: OuterScope SeparateDefinitionBlocks: Leave ShortNamespaceLines: 1 SortIncludes: Never SortJavaStaticImport: Before -SortUsingDeclarations: LexicographicNumeric +SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true -SpaceAroundPointerQualifiers: Default SpaceBeforeAssignmentOperators: true SpaceBeforeCaseColon: false SpaceBeforeCpp11BracedList: true SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true -SpaceBeforeJsonColon: false SpaceBeforeParens: ControlStatements SpaceBeforeParensOptions: AfterControlStatements: true @@ -202,22 +182,22 @@ SpaceBeforeParensOptions: AfterRequiresInClause: false AfterRequiresInExpression: false BeforeNonEmptyParentheses: false +SpaceAroundPointerQualifiers: Default SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeSquareBrackets: false SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: Never +SpacesInConditionalStatement: false SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false SpacesInLineCommentPrefix: Minimum: 1 Maximum: -1 -SpacesInParens: Never -SpacesInParensOptions: - InCStyleCasts: false - InConditionalStatements: false - InEmptyParentheses: false - Other: false +SpacesInParentheses: false SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +BitFieldColonSpacing: Both Standard: Latest StatementAttributeLikeMacros: - Q_EMIT @@ -225,13 +205,13 @@ StatementMacros: - Q_UNUSED - QT_REQUIRE_VERSION TabWidth: 8 +UseCRLF: false UseTab: Never -VerilogBreakBetweenInstancePorts: true WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE - BOOST_PP_STRINGIZE - - CF_SWIFT_NAME - NS_SWIFT_NAME - - PP_STRINGIZE - - STRINGIZE + - CF_SWIFT_NAME ... diff --git a/.clang-format.original b/.clang-format.original index 57d55c24..d1f38edc 100644 --- a/.clang-format.original +++ b/.clang-format.original @@ -28,24 +28,17 @@ AlignConsecutiveMacros: AcrossComments: false AlignCompound: false PadOperators: false -AlignConsecutiveShortCaseStatements: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCaseColons: false AlignEscapedNewlines: Right AlignOperands: Align -AlignTrailingComments: - Kind: Always - OverEmptyLines: 0 +AlignTrailingComments: true AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: true AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false -AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: Never AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None @@ -55,18 +48,17 @@ AttributeMacros: - __capability BinPackArguments: true BinPackParameters: true -BitFieldColonSpacing: Both BraceWrapping: AfterCaseLabel: false AfterClass: false AfterControlStatement: Never AfterEnum: false - AfterExternBlock: false AfterFunction: false AfterNamespace: false AfterObjCDeclaration: false AfterStruct: false AfterUnion: false + AfterExternBlock: false BeforeCatch: false BeforeElse: false BeforeLambdaBody: false @@ -75,28 +67,33 @@ BraceWrapping: SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true -BreakAfterAttributes: Never -BreakAfterJavaFieldAnnotations: false -BreakArrays: true BreakBeforeBinaryOperators: None BreakBeforeConceptDeclarations: Always BreakBeforeBraces: Attach -BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: BeforeColon -BreakInheritanceList: BeforeColon +BreakAfterJavaFieldAnnotations: false BreakStringLiterals: true ColumnLimit: 80 CommentPragmas: '^ IWYU pragma:' +QualifierAlignment: Leave CompactNamespaces: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true +DeriveLineEnding: true DerivePointerAlignment: false DisableFormat: false EmptyLineAfterAccessModifier: Never EmptyLineBeforeAccessModifier: LogicalBlock ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: BinPack +BasedOnStyle: '' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +AllowAllConstructorInitializersOnNextLine: true FixNamespaceComments: true ForEachMacros: - foreach @@ -121,30 +118,20 @@ IncludeCategories: IncludeIsMainRegex: '(Test)?$' IncludeIsMainSourceRegex: '' IndentAccessModifiers: false -IndentCaseBlocks: false IndentCaseLabels: false -IndentExternBlock: AfterExternBlock +IndentCaseBlocks: false IndentGotoLabels: true IndentPPDirectives: None +IndentExternBlock: AfterExternBlock IndentRequiresClause: true IndentWidth: 2 IndentWrappedFunctionNames: false InsertBraces: false -InsertNewlineAtEOF: false InsertTrailingCommas: None -IntegerLiteralSeparator: - Binary: 0 - BinaryMinDigits: 0 - Decimal: 0 - DecimalMinDigits: 0 - Hex: 0 - HexMinDigits: 0 JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: true -KeepEmptyLinesAtEOF: false LambdaBodyIndentation: Signature -LineEnding: DeriveLF MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 @@ -154,7 +141,6 @@ ObjCBlockIndentWidth: 2 ObjCBreakBeforeNestedBlockParam: true ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: true -PackConstructorInitializers: BinPack PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 @@ -163,33 +149,27 @@ PenaltyBreakOpenParenthesis: 0 PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 -PenaltyIndentedWhitespace: 0 PenaltyReturnTypeOnItsOwnLine: 60 +PenaltyIndentedWhitespace: 0 PointerAlignment: Right PPIndentWidth: -1 -QualifierAlignment: Leave ReferenceAlignment: Pointer ReflowComments: true RemoveBracesLLVM: false -RemoveParentheses: Leave -RemoveSemicolon: false RequiresClausePosition: OwnLine -RequiresExpressionIndentation: OuterScope SeparateDefinitionBlocks: Leave ShortNamespaceLines: 1 SortIncludes: CaseSensitive SortJavaStaticImport: Before -SortUsingDeclarations: LexicographicNumeric +SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true -SpaceAroundPointerQualifiers: Default SpaceBeforeAssignmentOperators: true SpaceBeforeCaseColon: false SpaceBeforeCpp11BracedList: false SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true -SpaceBeforeJsonColon: false SpaceBeforeParens: ControlStatements SpaceBeforeParensOptions: AfterControlStatements: true @@ -201,22 +181,22 @@ SpaceBeforeParensOptions: AfterRequiresInClause: false AfterRequiresInExpression: false BeforeNonEmptyParentheses: false +SpaceAroundPointerQualifiers: Default SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeSquareBrackets: false SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: Never +SpacesInConditionalStatement: false SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false SpacesInLineCommentPrefix: Minimum: 1 Maximum: -1 -SpacesInParens: Never -SpacesInParensOptions: - InCStyleCasts: false - InConditionalStatements: false - InEmptyParentheses: false - Other: false +SpacesInParentheses: false SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +BitFieldColonSpacing: Both Standard: Latest StatementAttributeLikeMacros: - Q_EMIT @@ -224,13 +204,13 @@ StatementMacros: - Q_UNUSED - QT_REQUIRE_VERSION TabWidth: 8 +UseCRLF: false UseTab: Never -VerilogBreakBetweenInstancePorts: true WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE - BOOST_PP_STRINGIZE - - CF_SWIFT_NAME - NS_SWIFT_NAME - - PP_STRINGIZE - - STRINGIZE + - CF_SWIFT_NAME ... diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml new file mode 100644 index 00000000..f3a899e4 --- /dev/null +++ b/.github/workflows/codestyle.yml @@ -0,0 +1,10 @@ +name: Checking code style +on: [pull_request] +jobs: + check_cpp_codestyle: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - run: sudo apt install -y apt install clang-format-15 + - run: CHANGES=$(git diff -U0 --no-color "$GITHUB_BASE_REF" | clang-format-diff-15 -p1); [[ -n "$CHANGES" ]] || { echo "Please fix the following C++ style issues:"; echo "$CHANGES"; exit 2 }