From a1e534bbf076389321a7b0972451671b83b758e8 Mon Sep 17 00:00:00 2001 From: rkrux Date: Fri, 24 Apr 2026 17:29:12 +0530 Subject: [PATCH] doc: clarify clang-tidy in developer notes Recently, I ran clang-tidy in my system and had to figure out setting it up correcty on my system (macOS) & understanding its output while tweaking few arguments that made the output easier to parse. This patch documents those in the developer notes. --- doc/developer-notes.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 18691811aa4..f552b1d7338 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -164,7 +164,7 @@ To run clang-tidy on Ubuntu/Debian, install the dependencies: apt install clang-tidy clang ``` -Configure with clang as the compiler: +Configure with clang as the compiler with the below command that should create a `compile_commands.json` file within the build directory: ```sh cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON @@ -172,12 +172,19 @@ cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXP The output is denoised of errors from external dependencies. -To run clang-tidy on all source files: +To run clang-tidy on all source files using the checks mentioned in the `./src/.clang-tidy` file: ```sh ( cd ./src/ && run-clang-tidy -p ../build -j $(nproc) ) ``` +To run clang-tidy on one file: +```sh +( cd ./src/ && run-clang-tidy -p ../build -j $(nproc) ./path/to/single_file.cpp ) +``` + +Optionally, append the `run-clang-tidy` command with the `-quiet` option to suppress printing of statistics and ignored warnings that can clutter the output. The `-fix` option also comes in handy to apply the fixes suggested by the tool but need to ensure that unrelated changes in the file are not committed. + To run clang-tidy on the changed source lines: ```sh