Skip to content

Commit

Permalink
try fix clang format/tidy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
serges147 committed May 6, 2024
1 parent 0f5469e commit 9cc4fab
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
run: |
sudo apt update
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 18
sudo apt install clang-tidy-18 clang-format-12
sudo apt install clang-tidy-18 clang-format-18
- name: Static analysis
working-directory: ${{github.workspace}}/stm32/libcanard/bxcan/
Expand All @@ -61,6 +61,6 @@ jobs:
- name: Format check
working-directory: ${{github.workspace}}/stm32/libcanard/bxcan/
run: |
clang-format-12 -i -fallback-style=none -style=file --verbose src/*.[ch]
clang-format-18 -i -fallback-style=none -style=file --verbose src/*.[ch]
modified="$(git status --porcelain --untracked-files=no)"
if [ -n "$modified" ]; then echo "Please format code properly."; exit 1; fi
68 changes: 29 additions & 39 deletions socketcan/libcanard/.clang-format
Original file line number Diff line number Diff line change
@@ -1,67 +1,61 @@
---
Language: Cpp
# BasedOnStyle: LLVM
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
SplitEmptyRecord: false
AfterEnum: true
AfterStruct: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
AfterNamespace: true
AfterExternBlock: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
AfterExternBlock: false # Keeps the contents un-indented.
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom

BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
# BreakInheritanceList: AfterColon
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ (coverity|pragma:)'
ColumnLimit: 120
CommentPragmas: '^ (coverity|pragma:)'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
DisableFormat: false
FixNamespaceComments: true
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeBlocks: Preserve
IndentCaseLabels: false
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakAssignment: 2
Expand All @@ -72,25 +66,21 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 10000 # Raised intentionally because it hurts readability
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
ReflowComments: true
SortIncludes: Never
SortUsingDeclarations: false
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeCtorInitializerColon: true
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
Standard: c++14
TabWidth: 8
UseTab: Never
...
68 changes: 29 additions & 39 deletions stm32/libcanard/.clang-format
Original file line number Diff line number Diff line change
@@ -1,67 +1,61 @@
---
Language: Cpp
# BasedOnStyle: LLVM
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
SplitEmptyRecord: false
AfterEnum: true
AfterStruct: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
AfterNamespace: true
AfterExternBlock: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
AfterExternBlock: false # Keeps the contents un-indented.
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom

BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
# BreakInheritanceList: AfterColon
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ (coverity|pragma:)'
ColumnLimit: 120
CommentPragmas: '^ (coverity|pragma:)'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
DisableFormat: false
FixNamespaceComments: true
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeBlocks: Preserve
IndentCaseLabels: false
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakAssignment: 2
Expand All @@ -72,25 +66,21 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 10000 # Raised intentionally because it hurts readability
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
ReflowComments: true
SortIncludes: Never
SortUsingDeclarations: false
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeCtorInitializerColon: true
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
Standard: c++14
TabWidth: 8
UseTab: Never
...
5 changes: 3 additions & 2 deletions stm32/libcanard/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ Checks: >-
performance-*,
portability-*,
readability-*,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-macro-to-enum,modernize-macro-to-enum,
-google-readability-todo,
-readability-avoid-const-params-in-decls,
-llvm-header-guard,
-cppcoreguidelines-avoid-magic-numbers,
-readability-avoid-const-params-in-decls,
-readability-magic-numbers,
CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
Expand Down

0 comments on commit 9cc4fab

Please sign in to comment.