Skip to content

Commit 32a7ae1

Browse files
committed
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 #258 (comment) for more information. Signed-off-by: Abrar Rahman Protyasha <[email protected]>
1 parent 3113cc9 commit 32a7ae1

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

tf2/CMakeLists.txt

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,39 @@ install(DIRECTORY include/${PROJECT_NAME}/
4545

4646
# Tests
4747
if(BUILD_TESTING)
48-
# TODO(clalancette) enable linters once https://github.com/ament/ament_lint/pull/238 lands
48+
find_package(ament_cmake_copyright REQUIRED)
49+
find_package(ament_cmake_cppcheck REQUIRED)
50+
find_package(ament_cmake_cpplint REQUIRED)
51+
find_package(ament_cmake_lint_cmake REQUIRED)
52+
find_package(ament_cmake_uncrustify REQUIRED)
53+
find_package(ament_cmake_xmllint REQUIRED)
4954

50-
find_package(ament_cmake_gtest)
55+
# Should not lint external code
56+
set(
57+
_linter_excludes
58+
include/tf2/LinearMath/Matrix3x3.h
59+
include/tf2/LinearMath/MinMax.h
60+
include/tf2/LinearMath/QuadWord.h
61+
include/tf2/LinearMath/Quaternion.h
62+
include/tf2/LinearMath/Scalar.h
63+
include/tf2/LinearMath/Transform.h
64+
include/tf2/LinearMath/Vector3.h
65+
)
66+
67+
ament_copyright(EXCLUDE ${_linter_excludes})
68+
ament_cppcheck(
69+
EXCLUDE ${_linter_excludes}
70+
LANGUAGE c++
71+
)
72+
ament_cpplint(EXCLUDE ${_linter_excludes})
73+
ament_lint_cmake()
74+
ament_uncrustify(
75+
EXCLUDE ${_linter_excludes}
76+
LANGUAGE c++
77+
)
78+
ament_xmllint()
79+
80+
find_package(ament_cmake_gtest REQUIRED)
5181

5282
ament_add_gtest(test_cache_unittest test/cache_unittest.cpp)
5383
if(TARGET test_cache_unittest)

tf2/package.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@
2929
<depend>rcutils</depend>
3030

3131
<test_depend>ament_cmake_gtest</test_depend>
32-
<test_depend>ament_lint_auto</test_depend>
33-
<test_depend>ament_lint_common</test_depend>
32+
<test_depend>ament_cmake_copyright</test_depend>
33+
<test_depend>ament_cmake_cppcheck</test_depend>
34+
<test_depend>ament_cmake_cpplint</test_depend>
35+
<test_depend>ament_cmake_lint_cmake</test_depend>
36+
<test_depend>ament_cmake_uncrustify</test_depend>
37+
<test_depend>ament_cmake_xmllint</test_depend>
3438

3539
<export>
3640
<build_type>ament_cmake</build_type>

0 commit comments

Comments
 (0)