Skip to main content

Tools

The tools module integrates clang-tidy for static analysis and clang-format for automatic code formatting. Together, they enforce the coding standards defined in ADR-0006 — Code Style and Conventions, which specifies the naming rules, complexity limits, and formatting conventions for all Ideal components.

Tool discovery

The module searches for the run-clang-tidy wrapper script, which parallelizes clang-tidy across all translation units in a compilation database. If the script is not found and the compiler is Clang, the module retries with a version-suffixed name (run-clang-tidy-<major>) to match the installed compiler version.

If clang-format is also found, it is used together with clang-tidy so that files are automatically reformatted after fixes are applied.

Build targets

TargetDescription
tidyRuns clang-tidy with auto-fix on all sources in the project

The tidy target is only available when run-clang-tidy is found and the project is top-level. When clang-format is also available, the target reformats modified files after applying fixes.

The target relies on a compile_commands.json file in the build directory — generated automatically by CMake when using Ninja or when CMAKE_EXPORT_COMPILE_COMMANDS is ON — and on a .clang-tidy configuration file in the project root that defines which checks to run.

Variables defined

VariableDescription
CLANG_FORMATPath to the clang-format executable, or empty
RUN_CLANG_TIDYPath to the run-clang-tidy executable, or empty

Usage

make tidy