From e7e279c0dd65871c2159e8cb8c592516e2deee0d Mon Sep 17 00:00:00 2001 From: Abrar Rahman Protyasha Date: Sun, 17 Oct 2021 18:52:04 -0400 Subject: [PATCH] tf2: Enable common linter tests Each of the common linters were individually `find_package`-d and invoked in the CMakeLists.txt file. This is because there is no simple way to pass file exclusion information through `ament_lint_auto`. File exclusion is necessary because we do not want to run linters on the include/tf2/LinearMath/ headers, since these are external and periodically synced with upstream. See https://github.com/ros2/geometry2/pull/258#issuecomment-621499030 for more information. Signed-off-by: Abrar Rahman Protyasha --- tf2/CMakeLists.txt | 34 ++++++++++++++++++++++++++++++++-- tf2/package.xml | 8 ++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/tf2/CMakeLists.txt b/tf2/CMakeLists.txt index a03128a06..76ec7efbf 100644 --- a/tf2/CMakeLists.txt +++ b/tf2/CMakeLists.txt @@ -45,9 +45,39 @@ install(DIRECTORY include/${PROJECT_NAME}/ # Tests if(BUILD_TESTING) - # TODO(clalancette) enable linters once https://github.com/ament/ament_lint/pull/238 lands + find_package(ament_cmake_copyright REQUIRED) + find_package(ament_cmake_cppcheck REQUIRED) + find_package(ament_cmake_cpplint REQUIRED) + find_package(ament_cmake_lint_cmake REQUIRED) + find_package(ament_cmake_uncrustify REQUIRED) + find_package(ament_cmake_xmllint REQUIRED) - find_package(ament_cmake_gtest) + # Should not lint external code + set( + _linter_excludes + include/tf2/LinearMath/Matrix3x3.h + include/tf2/LinearMath/MinMax.h + include/tf2/LinearMath/QuadWord.h + include/tf2/LinearMath/Quaternion.h + include/tf2/LinearMath/Scalar.h + include/tf2/LinearMath/Transform.h + include/tf2/LinearMath/Vector3.h + ) + + ament_copyright(EXCLUDE ${_linter_excludes}) + ament_cppcheck( + EXCLUDE ${_linter_excludes} + LANGUAGE c++ + ) + ament_cpplint(EXCLUDE ${_linter_excludes}) + ament_lint_cmake() + ament_uncrustify( + EXCLUDE ${_linter_excludes} + LANGUAGE c++ + ) + ament_xmllint() + + find_package(ament_cmake_gtest REQUIRED) ament_add_gtest(test_cache_unittest test/cache_unittest.cpp) if(TARGET test_cache_unittest) diff --git a/tf2/package.xml b/tf2/package.xml index 87c9bac13..88136254f 100644 --- a/tf2/package.xml +++ b/tf2/package.xml @@ -29,8 +29,12 @@ rcutils ament_cmake_gtest - ament_lint_auto - ament_lint_common + ament_cmake_copyright + ament_cmake_cppcheck + ament_cmake_cpplint + ament_cmake_lint_cmake + ament_cmake_uncrustify + ament_cmake_xmllint ament_cmake