From 84c5ac173c99fc1aebfb1a857a900a3df4747b3b Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 23 Jun 2024 09:20:13 -0700 Subject: [PATCH 1/3] Adding a .clang-format file for this repo --- .clang-format | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..bb39ff0 --- /dev/null +++ b/.clang-format @@ -0,0 +1,87 @@ +Standard: Latest +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignConsecutiveMacros: AcrossEmptyLinesAndComments +AlignEscapedNewlines: Right +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: true +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +BreakAfterReturnType: TopLevelDefinitions +AlwaysBreakBeforeMultilineStrings: true +BreakTemplateDeclarations: No +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: Both +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterFunction: false + AfterControlStatement: false + SplitEmptyFunction: false + AfterEnum: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: true + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +ColumnLimit: 80 +CompactNamespaces: false +Cpp11BracedListStyle: true +DerivePointerAlignment: false +EmptyLineBeforeAccessModifier: LogicalBlock +FixNamespaceComments: true +IndentCaseLabels: false +IndentExternBlock: Indent +IndentRequires: false +IndentWidth: 2 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +PointerAlignment: Right +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: false +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesInContainerLiterals: false +SpacesInParens: Never +SpacesInSquareBrackets: false +UseTab: Never +SeparateDefinitionBlocks: Always +MaxEmptyLinesToKeep: 1 +ContinuationIndentWidth: 2 +SpacesBeforeTrailingComments: 2 +SortIncludes: true +IncludeBlocks: Regroup +NamespaceIndentation: None From a06a6185ce6403656078c137aa779a0cd3b31bd7 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 23 Jun 2024 09:53:35 -0700 Subject: [PATCH 2/3] Simplifying the .clang-format file for now --- .clang-format | 84 +-------------------------------------------------- 1 file changed, 1 insertion(+), 83 deletions(-) diff --git a/.clang-format b/.clang-format index bb39ff0..f6a4f8d 100644 --- a/.clang-format +++ b/.clang-format @@ -1,87 +1,5 @@ -Standard: Latest -AccessModifierOffset: -2 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: None -AlignConsecutiveBitFields: None -AlignConsecutiveDeclarations: None -AlignConsecutiveMacros: AcrossEmptyLinesAndComments -AlignEscapedNewlines: Right -AlignTrailingComments: true -AllowAllArgumentsOnNextLine: false -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: Always -AllowShortCaseLabelsOnASingleLine: false -AllowShortEnumsOnASingleLine: true -AllowShortFunctionsOnASingleLine: Inline -AllowShortIfStatementsOnASingleLine: true -AllowShortLambdasOnASingleLine: All -AllowShortLoopsOnASingleLine: true -BreakAfterReturnType: TopLevelDefinitions -AlwaysBreakBeforeMultilineStrings: true -BreakTemplateDeclarations: No -BinPackArguments: true -BinPackParameters: true -BitFieldColonSpacing: Both +BasedOnStyle: llvm BreakBeforeBraces: Custom BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterFunction: false - AfterControlStatement: false - SplitEmptyFunction: false - AfterEnum: false - AfterNamespace: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: true BeforeElse: true - BeforeLambdaBody: false - BeforeWhile: true - SplitEmptyRecord: false - SplitEmptyNamespace: false -BreakBeforeBinaryOperators: None -BreakBeforeConceptDeclarations: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializers: BeforeColon -BreakInheritanceList: BeforeColon -BreakStringLiterals: true -ColumnLimit: 80 -CompactNamespaces: false -Cpp11BracedListStyle: true -DerivePointerAlignment: false -EmptyLineBeforeAccessModifier: LogicalBlock -FixNamespaceComments: true -IndentCaseLabels: false -IndentExternBlock: Indent -IndentRequires: false -IndentWidth: 2 IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: false -PointerAlignment: Right -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: false -SpaceAroundPointerQualifiers: Default -SpaceBeforeAssignmentOperators: true -SpaceBeforeCaseColon: false -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: false -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeSquareBrackets: false -SpaceInEmptyBlock: false -SpaceInEmptyParentheses: false -SpacesInContainerLiterals: false -SpacesInParens: Never -SpacesInSquareBrackets: false -UseTab: Never -SeparateDefinitionBlocks: Always -MaxEmptyLinesToKeep: 1 -ContinuationIndentWidth: 2 -SpacesBeforeTrailingComments: 2 -SortIncludes: true -IncludeBlocks: Regroup -NamespaceIndentation: None From 6b951d4a1de6464e1c0bc882297b313b61b00f78 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 23 Jun 2024 09:56:46 -0700 Subject: [PATCH 3/3] Adding a workflow to check source code formatting for c++ files --- .github/workflows/source-format-check.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/source-format-check.yml diff --git a/.github/workflows/source-format-check.yml b/.github/workflows/source-format-check.yml new file mode 100644 index 0000000..8417af0 --- /dev/null +++ b/.github/workflows/source-format-check.yml @@ -0,0 +1,20 @@ +name: Source code format check + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + workflow_dispatch: + +jobs: + check-format: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install dependencies + run: sudo apt-get install -y clang-format + - name: Run clang-format + run: | + git $(ls-files '*.*pp') | xargs clang-format -n -Werror