ament / ament_lint

Apache License 2.0
37 stars 107 forks source link

ament_lint_auto finds recursive test dependencies causing downstream packages to inherit conflicting linters #461

Open Ryanf55 opened 10 months ago

Ryanf55 commented 10 months ago

Use case with current behavior

I'm trying to use a different python linter than flake8 because flake8 doesn't automatically correct your files.

ament_black is much better for new projects not in the ROS core because developers don't need to spend time on manual formatting. https://github.com/botsandus/ament_black

I create a package foo, and I also like using ament_lint_auto to specify all my linter dependencies. I do NOT depend on ament_lint_common because that has flake8, and flake8 doesn't agree with black.

package.xml

  <depend>std_msgs</depend>
  <test_depend>ament_cmake_black</test_depend>
  <test_depend>ament_cmake_copyright</test_depend>
  <test_depend>ament_cmake_lint_cmake</test_depend>
  <test_depend>ament_cmake_pep257</test_depend>
  <test_depend>ament_cmake_pytest</test_depend>
  <test_depend>ament_cmake_uncrustify</test_depend>
  <test_depend>ament_cmake_xmllint</test_depend>
  <test_depend>ament_lint_auto</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>

CMakeLists.txt

if(BUILD_TESTING)
  # Add linters.
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

Great!

Now, run the tests

colcon test --packages-select my_pkg
colcon test-result --all
colcon test-result --all | grep flake8
>>> build/ardupilot_msgs/test_results/ardupilot_msgs/flake8_rosidl_generated_py.xunit.xml: 1 test, 0 errors, 0 failures, 0 skipped

Oh no! flake8 is running, even though my package doesn't have test dependencies on it, nor does it use ament_lint_common!

Environment

Desired behavior

I am not forced to use linters I do not put in my package.xml as test_depend.