From d156caca6ab39e906da68682dc247ff15523e672 Mon Sep 17 00:00:00 2001 From: Aleksei Zhavoronkov Date: Fri, 6 Feb 2026 08:25:40 +0000 Subject: [PATCH] Pull request 616: lint-cpp: switch to clangd-tidy and drop *-magic-numbers Squashed commit of the following: commit 542ff3c79526154aedd899f870e3d2b3c415844c Author: Zhavoronkov Aleksei Date: Thu Feb 5 17:51:04 2026 +0300 lint-cpp: switch to clangd-tidy and drop *-magic-numbers Disable *-magic-numbers check because it takes a significant amount of time and no one actually uses it. Use clangd-tidy (https://github.com/lljbash/clangd-tidy) instead of clang-tidy in lint-cpp to speed up checks. Signed-off-by: Zhavoronkov Aleksei --- .clang-tidy | 4 +++- .clangd | 8 ++++++++ .github/workflows/run-tests.yml | 2 ++ Makefile | 13 +++++++++++-- bamboo-specs/run-tests.yaml | 1 + requirements.txt | 1 + 6 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 .clangd diff --git a/.clang-tidy b/.clang-tidy index 94dbf2c..0a52552 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -101,7 +101,9 @@ Checks: >- -cppcoreguidelines-use-enum-class, -portability-template-virtual-member-function, -modernize-use-integer-sign-comparison, - -misc-const-correctness + -misc-const-correctness, + -cppcoreguidelines-avoid-magic-numbers, + -readability-magic-numbers WarningsAsErrors: '*' diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..a586e7e --- /dev/null +++ b/.clangd @@ -0,0 +1,8 @@ +CompileFlags: + # TODO: Remove when https://github.com/clangd/clangd/issues/1167 will be fixed + Add: [-Wno-unknown-pragmas] +Diagnostics: + # Available in clangd-14 + UnusedIncludes: None + # Requires clangd-17 + MissingIncludes: None \ No newline at end of file diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 501e92a..6bda50b 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -35,6 +35,7 @@ jobs: - name: Install packages run: | sudo apt install -y ninja-build + pip install -r requirements.txt pip install conan~=$CONAN_VER pip install clang-format~=$CLANG_FORMAT_VER ## Install LLVM @@ -130,6 +131,7 @@ jobs: - name: Install packages run: | brew install ninja llvm@21 + pip install -r requirements.txt pip install conan~=$CONAN_VER pip install clang-format~=$CLANG_FORMAT_VER echo "/opt/homebrew/opt/llvm@21/bin" >> $GITHUB_PATH diff --git a/Makefile b/Makefile index fab62d7..db8eb5f 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ ifeq ($(origin MSVC_YEAR), undefined) endif endif BUILD_DIR = build +COMPILE_COMMANDS = $(BUILD_DIR)/compile_commands.json EXPORT_DIR ?= bin SETUP_WIZARD_DIR = trusttunnel/setup_wizard @@ -101,7 +102,7 @@ lint: lint-md lint-rust lint-cpp ## Lint c++ files. .PHONY: lint-cpp -lint-cpp: clang-format clang-tidy +lint-cpp: clang-format clangd-tidy ## Check c++ code formatting with clang-format. .PHONY: clang-format @@ -113,7 +114,15 @@ clang-format: ## Check c++ code formatting with clang-tidy. .PHONY: clang-tidy clang-tidy: compile_commands - run-clang-tidy -p $(BUILD_DIR) '^(?!.*(/third-party/)).*\.cpp$$' + run-clang-tidy -p $(BUILD_DIR) -config-file='.clang-tidy' '^(?!.*(/third-party/)).*\.cpp$$' + +## Check c++ code formatting with clangd-tidy. +.PHONY: clangd-tidy +clangd-tidy: compile_commands + jq -r '.[] | select(.file | endswith(".cpp")) | .file' $(COMPILE_COMMANDS) \ + | grep -vE '(^|/)(third-party)(/|$$)' \ + | sort -u \ + | xargs clangd-tidy -p $(BUILD_DIR) ## Lint markdown files. ## `markdownlint-cli` should be installed: diff --git a/bamboo-specs/run-tests.yaml b/bamboo-specs/run-tests.yaml index 0665c92..41ae355 100644 --- a/bamboo-specs/run-tests.yaml +++ b/bamboo-specs/run-tests.yaml @@ -40,6 +40,7 @@ Run tests on Linux: - |- set -x -e + python3 -m pip install -r requirements.txt python3 -m pip install conan --upgrade conan remote add --index 0 art ${bamboo.conanRepoUrl} || true diff --git a/requirements.txt b/requirements.txt index 86d967e..bb8f49d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ pyyaml==6.0.3 +clangd-tidy \ No newline at end of file