Skip to content

Commit

Permalink
Updated linter and .clang-format for ROS2
Browse files Browse the repository at this point in the history
  • Loading branch information
bsutherland333 committed Dec 15, 2023
1 parent 8f8ea1c commit a0fd999
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 54 deletions.
111 changes: 63 additions & 48 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,53 +1,68 @@
---
Language: Cpp
BasedOnStyle: Google
IndentWidth: 2
UseTab: Never
ColumnLimit: 120
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
PointerAlignment: Left
# ROS2 code style standards
# https://docs.ros.org/en/humble/The-ROS2-Project/Contributing/Code-Style-Language-Versions.html#id3
BasedOnStyle: LLVM
AccessModifierOffset: -2
IndentCaseLabels: false
AlignAfterOpenBracket: Align
BinPackArguments: true
BinPackParameters: false
ExperimentalAutoDetectBinPacking: false
AlignConsecutiveAssignments: None
AlignOperands: DontAlign
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AlignTrailingComments: true
SpacesBeforeTrailingComments: 1
FixNamespaceComments: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Never
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: NonAssignment
BreakConstructorInitializers: AfterColon
ConstructorInitializerIndentWidth: 2

IncludeBlocks: Regroup
IncludeCategories:
- Regex: '"rosflight\.h"'
Priority: 3
- Regex: '"interface\/[[:alnum:]_]+\.h"'
Priority: 1
- Regex: '<turbomath\/[[:alnum:]_]+\.h>'
Priority: 4
- Regex: '<[[:alpha:]]+>'
Priority: 6
- Regex: '<.*>'
Priority: 5
- Regex: '".*"'
Priority: 2
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeColon
ColumnLimit: 100
CompactNamespaces: false
ContinuationIndentWidth: 2
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PointerAlignment: Middle
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 2
UseTab: Never
9 changes: 5 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: DoozyX/clang-format-lint-action@v0.5
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.16
with:
source: '.'
extensions: 'h,cpp'
clangFormatVersion: 6
extensions: 'h,hpp,cpp'
exclude: './boards/*/lib'
clangFormatVersion: 16
4 changes: 2 additions & 2 deletions scripts/fix-code-style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ SCRIPTPATH=`dirname $SCRIPT`
echo #SCRIPTPATH
cd $SCRIPTPATH/..

find . -iname "*.h" -o -iname "*.cpp" | \
egrep -v "^(./comms/mavlink/v1.0/|./boards/airbourne/airbourne/|./boards/breezy/breezystm32|./.git|./test/build)" | \
find . -iname "*.h" -o -iname "*.hpp" -o -iname "*.cpp" | \
grep -Ev "^(./comms/mavlink/v1.0/|./boards/airbourne/airbourne/|./boards/breezy/breezystm32|./.git|./test/build)" | \
xargs clang-format -i

0 comments on commit a0fd999

Please sign in to comment.