From d6d4b7032817ab76d41e4f1104f408da0a6c9065 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sat, 6 Dec 2025 22:51:12 +0000 Subject: [PATCH 1/8] Move linters to pre-commit --- .pre-commit-config.yaml | 34 +++++++++++++++++++ example/CMakeLists.txt | 6 ---- example/package.xml | 3 -- example_cmake_python/package.xml | 3 -- example_external/CMakeLists.txt | 8 ----- example_external/package.xml | 3 -- example_python/package.xml | 3 -- example_python/test/test_copyright.py | 27 --------------- example_python/test/test_flake8.py | 25 -------------- example_python/test/test_pep257.py | 23 ------------- generate_parameter_library/CMakeLists.txt | 8 ----- generate_parameter_library/package.xml | 3 -- generate_parameter_library_py/package.xml | 1 - .../test/test_copyright.py | 27 --------------- parameter_traits/CMakeLists.txt | 8 ----- parameter_traits/package.xml | 2 -- 16 files changed, 34 insertions(+), 150 deletions(-) delete mode 100644 example_python/test/test_copyright.py delete mode 100644 example_python/test/test_flake8.py delete mode 100644 example_python/test/test_pep257.py delete mode 100644 generate_parameter_library_py/test/test_copyright.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 034f8fbc..75d7b634 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -75,3 +75,37 @@ repos: rev: v3.21.2 hooks: - id: pyupgrade + + - repo: local + hooks: + - id: ament_cppcheck + name: ament_cppcheck + description: Static code analysis of C/C++ files. + entry: env AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS=1 ament_cppcheck + language: system + files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$ + - id: ament_cpplint + name: ament_cpplint + description: Static code analysis of C/C++ files. + entry: ament_cpplint + language: system + files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$ + args: ["--linelength=100", "--filter=-whitespace/newline"] + - id: ament_lint_cmake + name: ament_lint_cmake + description: Check format of CMakeLists.txt files. + entry: ament_lint_cmake + language: system + files: CMakeLists\.txt$ + - id: ament_copyright + name: ament_copyright + description: Check if copyright notice is available in all files. + entry: ament_copyright + language: system + exclude: .*/conf\.py$ + - id: ament_flake8 + name: ament_flake8 + description: Check Python code style using flake8. + language: system + types: [python] + entry: ament_flake8 diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index a61d2c81..24bb416d 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -36,12 +36,6 @@ rclcpp_components_register_node(minimal_publisher ) if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - set(ament_cmake_cpplint_FOUND TRUE) # Conflicts with clang-foramt - set(ament_cmake_flake8_FOUND TRUE) # Conflicts with black - set(ament_cmake_uncrustify_FOUND TRUE) # Conflicts with clang-format - ament_lint_auto_find_test_dependencies() - find_package(ament_cmake_gtest REQUIRED) # example_test_gtest add_rostest_with_parameters_gtest(test_example_gtest test/example_test_gtest.cpp diff --git a/example/package.xml b/example/package.xml index fbdf40c5..b2998c10 100644 --- a/example/package.xml +++ b/example/package.xml @@ -20,9 +20,6 @@ ament_cmake_core - ament_lint_auto - ament_lint_common - ament_cmake diff --git a/example_cmake_python/package.xml b/example_cmake_python/package.xml index ba577b4e..4e0459c8 100644 --- a/example_cmake_python/package.xml +++ b/example_cmake_python/package.xml @@ -17,9 +17,6 @@ ament_cmake_python - ament_lint_auto - ament_lint_common - ament_cmake diff --git a/example_external/CMakeLists.txt b/example_external/CMakeLists.txt index 40798728..77eff2cd 100644 --- a/example_external/CMakeLists.txt +++ b/example_external/CMakeLists.txt @@ -50,12 +50,4 @@ install( ament_export_targets(export_generate_parameter_library_example_external HAS_LIBRARY_TARGET) ament_export_dependencies(rclcpp rclcpp_components generate_parameter_library_example) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - set(ament_cmake_cpplint_FOUND TRUE) # Conflicts with clang-foramt - set(ament_cmake_flake8_FOUND TRUE) # Conflicts with black - set(ament_cmake_uncrustify_FOUND TRUE) # Conflicts with clang-format - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/example_external/package.xml b/example_external/package.xml index 9327d013..3f25f426 100644 --- a/example_external/package.xml +++ b/example_external/package.xml @@ -20,9 +20,6 @@ ament_cmake_core - ament_lint_auto - ament_lint_common - ament_cmake diff --git a/example_python/package.xml b/example_python/package.xml index 9be7bb95..bd69c236 100644 --- a/example_python/package.xml +++ b/example_python/package.xml @@ -15,9 +15,6 @@ generate_parameter_library_py rclpy - ament_copyright - ament_flake8 - ament_pep257 python3-pytest diff --git a/example_python/test/test_copyright.py b/example_python/test/test_copyright.py deleted file mode 100644 index d78c79bc..00000000 --- a/example_python/test/test_copyright.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_copyright.main import main -import pytest - - -# Remove the `skip` decorator once the source file(s) have a copyright header -@pytest.mark.skip( - reason='No copyright header has been placed in the generated source file.' -) -@pytest.mark.copyright -@pytest.mark.linter -def test_copyright(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found errors' diff --git a/example_python/test/test_flake8.py b/example_python/test/test_flake8.py deleted file mode 100644 index 26030113..00000000 --- a/example_python/test/test_flake8.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2017 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_flake8.main import main_with_errors -import pytest - - -@pytest.mark.flake8 -@pytest.mark.linter -def test_flake8(): - rc, errors = main_with_errors(argv=[]) - assert rc == 0, 'Found %d code style errors / warnings:\n' % len( - errors - ) + '\n'.join(errors) diff --git a/example_python/test/test_pep257.py b/example_python/test/test_pep257.py deleted file mode 100644 index b234a384..00000000 --- a/example_python/test/test_pep257.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_pep257.main import main -import pytest - - -@pytest.mark.linter -@pytest.mark.pep257 -def test_pep257(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' diff --git a/generate_parameter_library/CMakeLists.txt b/generate_parameter_library/CMakeLists.txt index 58b3c65e..8de2af22 100644 --- a/generate_parameter_library/CMakeLists.txt +++ b/generate_parameter_library/CMakeLists.txt @@ -9,14 +9,6 @@ install( DESTINATION share/generate_parameter_library ) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - set(ament_cmake_cpplint_FOUND TRUE) # Conflicts with clang-foramt - set(ament_cmake_flake8_FOUND TRUE) # Conflicts with black - set(ament_cmake_uncrustify_FOUND TRUE) # Conflicts with clang-format - ament_lint_auto_find_test_dependencies() -endif() - ament_package( CONFIG_EXTRAS "generate_parameter_library-extras.cmake" ) diff --git a/generate_parameter_library/package.xml b/generate_parameter_library/package.xml index 7ad1187c..01d36ce1 100644 --- a/generate_parameter_library/package.xml +++ b/generate_parameter_library/package.xml @@ -26,9 +26,6 @@ tcb_span tl_expected - ament_lint_auto - ament_lint_common - ament_cmake diff --git a/generate_parameter_library_py/package.xml b/generate_parameter_library_py/package.xml index f2ff0d18..4b68beae 100644 --- a/generate_parameter_library_py/package.xml +++ b/generate_parameter_library_py/package.xml @@ -17,7 +17,6 @@ python3-typeguard python3-yaml - ament_copyright python3-pytest diff --git a/generate_parameter_library_py/test/test_copyright.py b/generate_parameter_library_py/test/test_copyright.py deleted file mode 100644 index d78c79bc..00000000 --- a/generate_parameter_library_py/test/test_copyright.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_copyright.main import main -import pytest - - -# Remove the `skip` decorator once the source file(s) have a copyright header -@pytest.mark.skip( - reason='No copyright header has been placed in the generated source file.' -) -@pytest.mark.copyright -@pytest.mark.linter -def test_copyright(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found errors' diff --git a/parameter_traits/CMakeLists.txt b/parameter_traits/CMakeLists.txt index d4e6d6b2..92ef5423 100644 --- a/parameter_traits/CMakeLists.txt +++ b/parameter_traits/CMakeLists.txt @@ -23,14 +23,6 @@ target_link_libraries(parameter_traits tl_expected::tl_expected ) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following lines skip linters - set(ament_cmake_cpplint_FOUND TRUE) # Conflicts with clang-foramt - set(ament_cmake_uncrustify_FOUND TRUE) # Conflicts with clang-format - ament_lint_auto_find_test_dependencies() -endif() - install( DIRECTORY include/ DESTINATION include/parameter_traits diff --git a/parameter_traits/package.xml b/parameter_traits/package.xml index dec28799..5d5eb235 100644 --- a/parameter_traits/package.xml +++ b/parameter_traits/package.xml @@ -20,8 +20,6 @@ tl_expected ament_cmake_gtest - ament_lint_auto - ament_lint_common ament_cmake From f390d8f656bcface85d44651a9afe325cefe8c4d Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sat, 6 Dec 2025 22:52:36 +0000 Subject: [PATCH 2/8] Remove flake8 as we use black --- .pre-commit-config.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 75d7b634..fb7e0e83 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -103,9 +103,3 @@ repos: entry: ament_copyright language: system exclude: .*/conf\.py$ - - id: ament_flake8 - name: ament_flake8 - description: Check Python code style using flake8. - language: system - types: [python] - entry: ament_flake8 From fac70e06e8fe3f5c86aaac47b9d1525dd886a9af Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 7 Dec 2025 14:56:00 +0000 Subject: [PATCH 3/8] Add copyright notice to python files --- .../cpp_conversions.py | 30 ++++++++++++++++++ .../python_conversions.py | 30 ++++++++++++++++++ .../string_filters_cpp.py | 31 +++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/generate_parameter_library_py/generate_parameter_library_py/cpp_conversions.py b/generate_parameter_library_py/generate_parameter_library_py/cpp_conversions.py index 7b8b3d42..ba410a84 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/cpp_conversions.py +++ b/generate_parameter_library_py/generate_parameter_library_py/cpp_conversions.py @@ -1,3 +1,33 @@ +#!/usr/bin/env python3 + +# Copyright 2023 PickNik Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the PickNik Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + from typing import List, Union from jinja2 import Template from typeguard import typechecked diff --git a/generate_parameter_library_py/generate_parameter_library_py/python_conversions.py b/generate_parameter_library_py/generate_parameter_library_py/python_conversions.py index 37f04055..8185085b 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/python_conversions.py +++ b/generate_parameter_library_py/generate_parameter_library_py/python_conversions.py @@ -1,3 +1,33 @@ +#!/usr/bin/env python3 + +# Copyright 2023 PickNik Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the PickNik Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + from typing import List, Union from jinja2 import Template from typeguard import typechecked diff --git a/generate_parameter_library_py/generate_parameter_library_py/string_filters_cpp.py b/generate_parameter_library_py/generate_parameter_library_py/string_filters_cpp.py index 1ab82baf..45611c35 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/string_filters_cpp.py +++ b/generate_parameter_library_py/generate_parameter_library_py/string_filters_cpp.py @@ -1,3 +1,34 @@ +#!/usr/bin/env python3 + +# Copyright 2023 PickNik Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the PickNik Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + + def valid_string_cpp(description): """ Filter a string to make it a valid C++ string literal. From e1116b143d1b35098f6340b6af2f1f5f2f09943c Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 7 Dec 2025 15:11:06 +0000 Subject: [PATCH 4/8] Fix pre-commit and update clang format to match cpplint --- .clang-format | 17 ++--------- .../example_validators.hpp | 4 +-- .../minimal_publisher.hpp | 5 +++- example/test/descriptor_test_gtest.cpp | 6 ++-- example/test/example_test_gmock.cpp | 4 +-- example/test/example_test_gtest.cpp | 4 +-- example_python/setup.py | 30 +++++++++++++++++++ example_python/test/test_load_modules.py | 30 +++++++++++++++++++ generate_parameter_library_py/setup.py | 30 +++++++++++++++++++ .../parameter_traits/parameter_traits.hpp | 4 +++ 10 files changed, 110 insertions(+), 24 deletions(-) diff --git a/.clang-format b/.clang-format index b0bea41e..07eb8ffb 100644 --- a/.clang-format +++ b/.clang-format @@ -1,17 +1,6 @@ --- BasedOnStyle: Google DerivePointerAlignment: false -IncludeBlocks: Regroup -IncludeCategories: - # Headers in "" with extension. - - Regex: '"([A-Za-z0-9.\Q/-_\E])+"' - Priority: 1 - # Headers in <> without extension. - - Regex: '<([A-Za-z0-9\Q/-_\E])+>' - Priority: 2 - # Headers in <> from specific external libraries. - - Regex: '<(catch2|boost|rclcpp.*)\/' - Priority: 3 - # Headers in <> with extension. - - Regex: '<([A-Za-z0-9.\Q/-_\E])+>' - Priority: 4 +IncludeBlocks: Preserve +InsertBraces: true +--- diff --git a/example/include/generate_parameter_library_example/example_validators.hpp b/example/include/generate_parameter_library_example/example_validators.hpp index b6aef735..4b9922ba 100644 --- a/example/include/generate_parameter_library_example/example_validators.hpp +++ b/example/include/generate_parameter_library_example/example_validators.hpp @@ -30,9 +30,9 @@ #include -#include - #include + +#include #include namespace custom_validators { diff --git a/example/include/generate_parameter_library_example/minimal_publisher.hpp b/example/include/generate_parameter_library_example/minimal_publisher.hpp index 10fef024..4e5d94b9 100644 --- a/example/include/generate_parameter_library_example/minimal_publisher.hpp +++ b/example/include/generate_parameter_library_example/minimal_publisher.hpp @@ -28,6 +28,8 @@ #pragma once +#include + #include #include @@ -37,7 +39,8 @@ namespace admittance_controller { class MinimalPublisher : public rclcpp::Node { public: - MinimalPublisher(const rclcpp::NodeOptions& options = rclcpp::NodeOptions()); + explicit MinimalPublisher( + const rclcpp::NodeOptions& options = rclcpp::NodeOptions()); private: void timer_callback(); diff --git a/example/test/descriptor_test_gtest.cpp b/example/test/descriptor_test_gtest.cpp index ad349f2f..ed9d5bb8 100644 --- a/example/test/descriptor_test_gtest.cpp +++ b/example/test/descriptor_test_gtest.cpp @@ -29,13 +29,13 @@ // Author: Chance Cardona // +#include +#include + #include "generate_parameter_library_example/admittance_controller_parameters.hpp" #include "gtest/gtest.h" #include "rclcpp/rclcpp.hpp" -#include -#include - class DescriptorTest : public ::testing::Test { public: void SetUp() { diff --git a/example/test/example_test_gmock.cpp b/example/test/example_test_gmock.cpp index 63486c25..d483caf6 100644 --- a/example/test/example_test_gmock.cpp +++ b/example/test/example_test_gmock.cpp @@ -29,12 +29,12 @@ // Author: Denis Štogl // +#include + #include "generate_parameter_library_example/admittance_controller_parameters.hpp" #include "gmock/gmock.h" #include "rclcpp/rclcpp.hpp" -#include - class ExampleTest : public ::testing::Test { public: void SetUp() { diff --git a/example/test/example_test_gtest.cpp b/example/test/example_test_gtest.cpp index fcae688c..74a7a1b5 100644 --- a/example/test/example_test_gtest.cpp +++ b/example/test/example_test_gtest.cpp @@ -29,12 +29,12 @@ // Author: Denis Štogl // +#include + #include "generate_parameter_library_example/admittance_controller_parameters.hpp" #include "gtest/gtest.h" #include "rclcpp/rclcpp.hpp" -#include - class ExampleTest : public ::testing::Test { public: void SetUp() { diff --git a/example_python/setup.py b/example_python/setup.py index 16dd94e7..4a73423b 100644 --- a/example_python/setup.py +++ b/example_python/setup.py @@ -1,3 +1,33 @@ +#!/usr/bin/env python3 + +# Copyright 2023 PickNik Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the PickNik Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + import sys from setuptools import setup diff --git a/example_python/test/test_load_modules.py b/example_python/test/test_load_modules.py index 6edf0af4..b729c238 100644 --- a/example_python/test/test_load_modules.py +++ b/example_python/test/test_load_modules.py @@ -1,3 +1,33 @@ +#!/usr/bin/env python3 + +# Copyright 2023 PickNik Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the PickNik Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + import generate_parameter_module_example print(f'Imported module from: {generate_parameter_module_example.__file__}') diff --git a/generate_parameter_library_py/setup.py b/generate_parameter_library_py/setup.py index 7b541f7d..0b641edf 100644 --- a/generate_parameter_library_py/setup.py +++ b/generate_parameter_library_py/setup.py @@ -1,3 +1,33 @@ +#!/usr/bin/env python3 + +# Copyright 2023 PickNik Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the PickNik Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + from setuptools import find_packages from setuptools import setup diff --git a/parameter_traits/include/parameter_traits/parameter_traits.hpp b/parameter_traits/include/parameter_traits/parameter_traits.hpp index a44b484e..c59c83a0 100644 --- a/parameter_traits/include/parameter_traits/parameter_traits.hpp +++ b/parameter_traits/include/parameter_traits/parameter_traits.hpp @@ -29,6 +29,10 @@ #pragma once #include + +#include +#include + #include #include From 355ee23ddd3a875bff1b8b7b02e89d2794c0bcfd Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 7 Dec 2025 15:19:41 +0000 Subject: [PATCH 5/8] Fix license with new ament_copyright --- .../minimal_publisher_external.hpp | 46 +++++++++---------- .../src/minimal_publisher_external.cpp | 46 +++++++++---------- 2 files changed, 42 insertions(+), 50 deletions(-) diff --git a/example_external/include/generate_parameter_library_example_external/minimal_publisher_external.hpp b/example_external/include/generate_parameter_library_example_external/minimal_publisher_external.hpp index 6ce7f61f..56cbc92f 100644 --- a/example_external/include/generate_parameter_library_example_external/minimal_publisher_external.hpp +++ b/example_external/include/generate_parameter_library_example_external/minimal_publisher_external.hpp @@ -1,34 +1,30 @@ // Copyright 2025 Forssea Robotics -// // All rights reserved. // -// Software License Agreement (BSD License 2.0) -// // Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. // -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of the Forssea Robotics nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. +// * Neither the name of the Forssea Robotics nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. // -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. #pragma once diff --git a/example_external/src/minimal_publisher_external.cpp b/example_external/src/minimal_publisher_external.cpp index 7b613485..344c1cc8 100644 --- a/example_external/src/minimal_publisher_external.cpp +++ b/example_external/src/minimal_publisher_external.cpp @@ -1,34 +1,30 @@ // Copyright 2025 Forssea Robotics -// // All rights reserved. // -// Software License Agreement (BSD License 2.0) -// // Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. // -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of the Forssea Robotics nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. +// * Neither the name of the Forssea Robotics nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. // -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. #include "generate_parameter_library_example_external/minimal_publisher_external.hpp" From f8e421ddbfc89b839e2d0fa9870f026bb3ff7a23 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 7 Dec 2025 15:19:57 +0000 Subject: [PATCH 6/8] Allow multiple yaml documents --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb7e0e83..fd3eb430 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,6 +34,7 @@ repos: - id: check-vcs-permalinks - id: check-yaml exclude: generate_parameter_library_py/generate_parameter_library_py/test + args: ["--allow-multiple-documents"] - id: debug-statements - id: destroyed-symlinks - id: detect-private-key From a935981da814012d4c63d4302a7b33f0599a3939 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 7 Dec 2025 15:21:04 +0000 Subject: [PATCH 7/8] Fix include order --- .../generate_parameter_library_example/example_validators.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/include/generate_parameter_library_example/example_validators.hpp b/example/include/generate_parameter_library_example/example_validators.hpp index 4b9922ba..31a8f897 100644 --- a/example/include/generate_parameter_library_example/example_validators.hpp +++ b/example/include/generate_parameter_library_example/example_validators.hpp @@ -28,10 +28,10 @@ #pragma once -#include - #include +#include + #include #include From 0c76dfebc8122a7cdf9313f3b02f2012a835a2ca Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 7 Dec 2025 15:27:22 +0000 Subject: [PATCH 8/8] Use ros2_control_ci to get ament linters preinstalled --- .github/workflows/format.yaml | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml index 7045141c..594b13cd 100644 --- a/.github/workflows/format.yaml +++ b/.github/workflows/format.yaml @@ -1,6 +1,3 @@ -# This is a format job. Pre-commit has a first-party GitHub action, so we use -# that: https://github.com/pre-commit/action - name: Format on: @@ -12,17 +9,6 @@ on: jobs: pre-commit: - name: pre-commit - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: actions/setup-python@v6 - - name: Install clang-format - run: sudo apt-get install clang-format - - uses: pre-commit/action@v3.0.1 - id: precommit - - name: Upload pre-commit changes - if: failure() && steps.precommit.outcome == 'failure' - uses: rhaschke/upload-git-patch-action@main - with: - name: pre-commit + uses: ros-controls/ros2_control_ci/.github/workflows/reusable-pre-commit.yml@master + with: + ros_distro: rolling