Applying Clang-Tidy to ROS packages#
Clang-Tidy is a powerful C++ linter.
Preparation#
You need to generate build/compile_commands.json
before using Clang-Tidy.
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1
Usage#
clang-tidy -p build/ path/to/file1 path/to/file2 ...
If you want to apply Clang-Tidy to all files in a package, using the fd command is useful.
To install fd
, see the installation manual.
clang-tidy -p build/ $(fd -e cpp -e hpp --full-path "/autoware_utils/")
IDE integration#
CLion#
Refer to the CLion Documentation.
Visual Studio Code#
Use either one of the following extensions:
Troubleshooting#
If you encounter clang-diagnostic-error
, try installing libomp-dev
.
Related: https://github.com/autowarefoundation/autoware-github-actions/pull/172