Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Add static code analyzing (clang-tidy) #185

Merged
merged 4 commits into from
Jul 29, 2019
Merged
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
66 changes: 66 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
Checks: '-*,
performance-*,
llvm-namespace-comment,
modernize-redundant-void-arg,
modernize-use-nullptr,
modernize-use-default,
modernize-use-override,
modernize-loop-convert,
readability-named-parameter,
readability-redundant-smartptr-get,
readability-redundant-string-cstr,
readability-simplify-boolean-expr,
readability-container-size-empty,
readability-identifier-naming,
'
# WarningsAsErrors: '
# performance-*,
# llvm-namespace-comment,
# modernize-redundant-void-arg,
# modernize-use-nullptr,
# modernize-use-default,
# modernize-use-override,
# modernize-loop-convert,
# readability-named-parameter,
# readability-redundant-smartptr-get,
# readability-redundant-string-cstr,
# readability-simplify-boolean-expr,
# readability-container-size-empty,
# readability-identifier-naming,
# '

HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
CheckOptions:
- key: llvm-namespace-comment.ShortNamespaceLines
value: '10'
- key: llvm-namespace-comment.SpacesBeforeComments
value: '2'
- key: readability-braces-around-statements.ShortStatementLines
value: '2'
# type names
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.UnionCase
value: CamelCase
# method names
- key: readability-identifier-naming.MethodCase
value: camelBack
# variable names
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.ClassMemberSuffix
value: '_'
# const static or global variables are UPPER_CASE
- key: readability-identifier-naming.EnumConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.StaticConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.ClassConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.GlobalVariableCase
value: UPPER_CASE
...
15 changes: 15 additions & 0 deletions pilz_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ add_definitions(-std=c++11)

include_directories(include ${Boost_INCLUDE_DIR} ${catkin_INCLUDE_DIRS})

################
## Clang tidy ##
################
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy-6.0"
DOC "Path to clang-tidy executable"
)
if(NOT CLANG_TIDY_EXE)
message(FATAL_ERROR "clang-tidy-6.0 not found.")
else()
message(STATUS "clang-tidy-6.0 found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif()

add_library(${PROJECT_NAME}
include/${PROJECT_NAME}/pilz_joint_trajectory_controller.h
src/pilz_joint_trajectory_controller.cpp)
Expand Down
1 change: 1 addition & 0 deletions pilz_control/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<buildtool_depend>catkin</buildtool_depend>

<build_depend>clang-tidy</build_depend>
<build_depend>cmake_modules</build_depend>
<build_depend>roslint</build_depend>

Expand Down
15 changes: 15 additions & 0 deletions pilz_testutils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ catkin_package(
LIBRARIES ${PROJECT_NAME}
)

################
## Clang tidy ##
################
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy-6.0"
DOC "Path to clang-tidy executable"
)
if(NOT CLANG_TIDY_EXE)
message(FATAL_ERROR "clang-tidy-6.0 not found.")
else()
message(STATUS "clang-tidy-6.0 found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif()

###########
## Build ##
###########
Expand Down
1 change: 1 addition & 0 deletions pilz_testutils/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@

<buildtool_depend>catkin</buildtool_depend>

<build_depend>clang-tidy</build_depend>
<build_depend>roscpp</build_depend>
</package>
15 changes: 15 additions & 0 deletions prbt_gazebo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ find_package(catkin REQUIRED COMPONENTS actionlib roscpp trajectory_msgs)

catkin_package()

################
## Clang tidy ##
################
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy-6.0"
DOC "Path to clang-tidy executable"
)
if(NOT CLANG_TIDY_EXE)
message(FATAL_ERROR "clang-tidy-6.0 not found.")
else()
message(STATUS "clang-tidy-6.0 found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif()

#############
## Install ##
#############
Expand Down
2 changes: 2 additions & 0 deletions prbt_gazebo/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

<buildtool_depend>catkin</buildtool_depend>

<build_depend>clang-tidy</build_depend>

<exec_depend>xacro</exec_depend>
<exec_depend>roslaunch</exec_depend>
<exec_depend>gazebo_ros</exec_depend>
Expand Down
15 changes: 15 additions & 0 deletions prbt_hardware_support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ catkin_package(
CATKIN_DEPENDS message_runtime std_msgs std_srvs sensor_msgs
)

################
## Clang tidy ##
################
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy-6.0"
DOC "Path to clang-tidy executable"
)
if(NOT CLANG_TIDY_EXE)
message(FATAL_ERROR "clang-tidy-6.0 not found.")
else()
message(STATUS "clang-tidy-6.0 found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif()

###########
## Build ##
###########
Expand Down
3 changes: 3 additions & 0 deletions prbt_hardware_support/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
<url type="repository">https://github.com/PilzDE/pilz_robots</url>

<buildtool_depend>catkin</buildtool_depend>

<build_depend>canopen_chain_node</build_depend>
<build_depend>clang-tidy</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>libmodbus-dev</build_depend>
<build_depend>message_generation</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>std_srvs</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>message_filters</build_depend>

<run_depend>roscpp</run_depend>
<run_depend>message_runtime</run_depend>
<run_depend>std_msgs</run_depend>
Expand Down
21 changes: 18 additions & 3 deletions prbt_ikfast_manipulator_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ add_compile_options(-Wno-unused-variable)
add_compile_options(-Werror)

# enable aligned new in gcc7+
if(CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
if(CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new")
endif()
endif()
endif()

find_package(catkin REQUIRED COMPONENTS
Expand All @@ -35,6 +35,21 @@ target_link_libraries(${IKFAST_LIBRARY_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARI
# suppress warnings about unused variables in OpenRave's solver code
target_compile_options(${IKFAST_LIBRARY_NAME} PRIVATE -Wno-unused-variable)

################
## Clang tidy ##
################
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy-6.0"
DOC "Path to clang-tidy executable"
)
if(NOT CLANG_TIDY_EXE)
message(FATAL_ERROR "clang-tidy-6.0 not found.")
else()
message(STATUS "clang-tidy-6.0 found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif()

install(TARGETS
${IKFAST_LIBRARY_NAME}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
Expand Down
1 change: 1 addition & 0 deletions prbt_ikfast_manipulator_plugin/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<export>
<moveit_core plugin="${prefix}/prbt_manipulator_moveit_ikfast_plugin_description.xml"/>
</export>
<build_depend>clang-tidy</build_depend>
<build_depend>eigen_conversions</build_depend>
<build_depend>liblapack-dev</build_depend>
<build_depend>moveit_core</build_depend>
Expand Down
16 changes: 15 additions & 1 deletion prbt_support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ catkin_package(
INCLUDE_DIRS
)

################
## Clang tidy ##
################
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy-6.0"
DOC "Path to clang-tidy executable"
)
if(NOT CLANG_TIDY_EXE)
message(FATAL_ERROR "clang-tidy-6.0 not found.")
else()
message(STATUS "clang-tidy-6.0 found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif()

#############
## Install ##
#############
Expand Down Expand Up @@ -51,4 +66,3 @@ if(CATKIN_ENABLE_TESTING)
roslaunch_add_file_check(launch)

endif()

2 changes: 2 additions & 0 deletions prbt_support/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<url type="repository">https://github.com/PilzDE/pilz_robots</url>

<buildtool_depend>catkin</buildtool_depend>

<build_depend>clang-tidy</build_depend>
<build_depend>roscpp</build_depend>

<exec_depend>roscpp</exec_depend>
Expand Down