ament_clang_tidy
Checks the code style of C / C++ source files using Clang-Tidy.
Files with the following extensions are considered:
.c, .cc, .cpp, .cxx, .h, .hh, .hpp, .hxx.
How to run the check from the command line?
Prerequisites: clang-tidy-6.0, clang-tools-6.0, and python-yaml packages should
have already been installed. compile_commands.json files should have already been generated
(e.g.: workspace built with colcon build --mixin compile-commands).
ament_clang_tidy [-h] [--config path] [--explain-config]
[--export-fixes EXPORT_FIXES] [--fix-errors]
[--header-filter HEADER_FILTER] [--quiet]
[--system-headers] [--jobs N]
[--packages-select [PKG_NAME [PKG_NAME ...]]]
[--xunit-file XUNIT_FILE]
[paths [paths ...]]
If <paths> is a directory, it will be recursively searched for
“compile_commands.json” files (this is usually the build directory of a
colcon workspace). If <paths> is a file, it will be treated as a
“compile_commands.json” file.
The --config allows you to set the path to the .clang-tidy file to use.
The --explain-config option will explain the origin of the enabled
configuration checks.
The --header-filter option will accept a regex and display errors from
the specified non-system header files. To display errors from all non-system
header, use --header-filter='.*'.
The --quiet option will suppress printing statistics about ignored
warnings and warnings treated as errors.
The --export-fixes option will generate a DAT file of the recorded
fixes when supplied with a file name.
When using the option --fix-errors the proposed changes are
applied in place.
The --system-headers option will display errors from all system header
files.
The --jobs option will control the number of clang-tidy jobs to run in
parallel.
The --packages-select option will filter the “compile_commands.json” files
to just those generated by specific ROS packages.
The --xunit-file option will generate a xunit compliant XML file when
supplied with a file name.
How to run the check from within a CMake ament package as part of the tests?
The CMake integration is provided by the package ament_cmake_clang_tidy.