'Why can't I use ament_cpplint with cpplint plugins for various IDEs?

I am working with C++ code with ROS2. ROS2 has code style standards and one of the recommended linters is ament_cpplint, which is slightly different from cpplint

Most IDEs/Editors for C++ (Clion, Atom, VS Code, Sublime Text) have plugins for cpplint which will run periodic linter checks as you are editing files. You usually have to set the path to the cpplint executable on your computer. I've tried to set the path to ament_cpplint executable instead but it just won't work. I've tried this with multiple IDEs and plugins by now and none of them will work.

I am not sure what's causing this, Google's cpplint works with IDEs. And I can run $ ament_cpplint from the command line just fine, but I can't get it to work in an IDE.



Solution 1:[1]

This might be too late for you, but for others.

You need to pass the path to the cpplint.py executable that is inside the ament_cpplint package.

For ros2 galactic, it is located here:
/opt/ros/galactic/lib/python3.8/site-packages/ament_cpplint/cpplint.py

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ejalaa12