Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom clang-format, re-format all code #2

Open
wants to merge 7 commits into
base: jazzy-2.0RC
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions puma_motor_driver/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
BasedOnStyle: Google
AccessModifierOffset: -2
AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
Enabled: true
AlignCompound: true
AlignConsecutiveDeclarations:
Enabled: true
PadOperators: true
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
PadOperators: true
AlignTrailingComments:
OverEmptyLines: 1
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: InlineOnly
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: "true"
AfterControlStatement: Always
AfterEnum: "true"
AfterFunction: "true"
AfterNamespace: "true"
AfterObjCDeclaration: false
AfterStruct: "true"
AfterUnion: "true"
AfterExternBlock: false
BeforeCatch: "true"
BeforeElse: "true"
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: "false"
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakAfterReturnType: Automatic
BreakBeforeBinaryOperators: false
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: BeforeComma
BreakTemplateDeclarations: MultiLine
ColumnLimit: 120
ConstructorInitializerIndentWidth: 2
Cpp11BracedListStyle: false
DerivePointerAlignment: false
InsertNewlineAtEOF: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 60
PenaltyBreakFirstLessLess: 1000
PenaltyBreakString: 1
PenaltyExcessCharacter: 1000
PenaltyReturnTypeOnItsOwnLine: 90
SortIncludes: false
SpacesInAngles: false
TabWidth: 2
13 changes: 6 additions & 7 deletions puma_motor_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ install(TARGETS multi_puma_node

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
list(APPEND AMENT_LINT_AUTO_EXCLUDE
ament_cmake_copyright
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this pass if enabled?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No:

test 1
    Start 1: copyright

1: Test command: /usr/bin/python3 "-u" "/opt/ros/jazzy/share/ament_cmake_test/cmake/run_test.py" "/home/civerachb/Code/clearpath_common_ws/build/puma_motor_driver/test_results/puma_motor_driver/copyright.xunit.xml" "--package-name" "puma_motor_driver" "--output-file" "/home/civerachb/Code/clearpath_common_ws/build/puma_motor_driver/ament_copyright/copyright.txt" "--command" "/opt/ros/jazzy/bin/ament_copyright" "--xunit-file" "/home/civerachb/Code/clearpath_common_ws/build/puma_motor_driver/test_results/puma_motor_driver/copyright.xunit.xml"
1: Working Directory: /home/civerachb/Code/clearpath_common_ws/src/clearpath_motor_drivers/puma_motor_driver
1: Test timeout computed to be: 200
1: -- run_test.py: invoking following command in '/home/civerachb/Code/clearpath_common_ws/src/clearpath_motor_drivers/puma_motor_driver':
1:  - /opt/ros/jazzy/bin/ament_copyright --xunit-file /home/civerachb/Code/clearpath_common_ws/build/puma_motor_driver/test_results/puma_motor_driver/copyright.xunit.xml
1: include/puma_motor_driver/can_proto.hpp: copyright=Texas Instruments Incorporated.  All rights reserved. (2008-2013), license=<unknown>
1: include/puma_motor_driver/driver.hpp: copyright=Clearpath Robotics, Inc., All rights reserved. (2015), license=<unknown>
1: include/puma_motor_driver/multi_puma_node.hpp: copyright=Clearpath Robotics, Inc., All rights reserved. (2024), license=<unknown>
1: src/driver.cpp: copyright=Clearpath Robotics, Inc., All rights reserved. (2015), license=<unknown>
1: src/multi_puma_node.cpp: copyright=Clearpath Robotics, Inc., All rights reserved. (2024), license=<unknown>
1: 5 errors, checked 5 files
1: -- run_test.py: return code 1
1: -- run_test.py: verify result file '/home/civerachb/Code/clearpath_common_ws/build/puma_motor_driver/test_results/puma_motor_driver/copyright.xunit.xml'
1/4 Test #1: copyright ........................***Failed    0.59 sec

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we added a "clearpath" copyright type the can_proto file would fail. There might be a way to set the test to pass if any copyright is found.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like you can... So the best option would be to copy what otto did and also exclude the TI file.

ament_cmake_cpplint
ament_cmake_uncrustify
)
set(ament_cmake_clang_format_CONFIG_FILE .clang-format)
ament_lint_auto_find_test_dependencies()
endif()

Expand Down
Loading
Loading