From 65f42d27525c8e4008e7f1e67f03204d430ce581 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com> Date: Mon, 9 Nov 2026 20:54:47 +0000 Subject: [PATCH] perf: leave `clang-analyzer-*` out of the default `--tidy-checks` The Clang Static Analyzer checks can make clang-tidy many times slower (see #518). clang-tidy 22 removed them from its own defaults, but our default added them back. Users can still enable them in a .clang-tidy file or with --tidy-checks. Document the change in the CLI help and the migration guide, including that clang-tidy 21 and older still enable them by default. Part of #518 --- cpp-linter/src/cli/mod.rs | 7 ++++++- docs/docs/migration.md | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cpp-linter/src/cli/mod.rs b/cpp-linter/src/cli/mod.rs index 5c57ac11..4e8c04e3 100644 --- a/cpp-linter/src/cli/mod.rs +++ b/cpp-linter/src/cli/mod.rs @@ -403,12 +403,17 @@ pub struct TidyOptions { /// `'-*'`. /// - It is also possible to rely solely on a .clang-tidy config file by /// specifying this option as a blank string (`''`). + /// - The default does not add the Clang Static Analyzer checks + /// (`clang-analyzer-*`) because they can make clang-tidy many times slower. + /// clang-tidy 22 and newer also leave them out of their own defaults. + /// clang-tidy 21 and older still enable them unless `-clang-analyzer-*` is added. + /// Add `clang-analyzer-*` to this option or to a .clang-tidy file to enable them. /// /// See also clang-tidy docs for more info. #[cfg_attr(feature = "bin", arg( short = 'c', long, - default_value = "boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*", + default_value = "boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,cppcoreguidelines-*", default_missing_value = "", num_args = 0..=1, help_heading = "Clang-tidy options", diff --git a/docs/docs/migration.md b/docs/docs/migration.md index 6e2a7e30..30a2516f 100644 --- a/docs/docs/migration.md +++ b/docs/docs/migration.md @@ -6,6 +6,7 @@ [mod-sys]: cli.md#-mod-sys [no-mod-sys]: cli.md#-no-mod-sys [ignore]: cli.md#-i-ignore +[tidy-checks]: cli.md#-c-tidy-checks [database]: cli.md#-p-database [repo-root]: cli.md#-r-repo-root [pr-review]: cli.md#-p-pr-review @@ -77,6 +78,7 @@ The old names can still be given together, as in v1 (for example |---|---|---| | [`-l`, `--lines-changed-only`][lines-changed-only] | `false` | `true` | | [`-i`, `--ignore`][ignore] | `.github` | `.github` and `target` | +| [`-c`, `--tidy-checks`][tidy-checks] | includes `clang-analyzer-*` | no `clang-analyzer-*` | Because `--lines-changed-only` is `true` by default and implies [`--files-changed-only`][files-changed-only], v2 analyzes only the added lines of changed files @@ -87,6 +89,17 @@ including files under `target`, pass: cpp-linter --lines-changed-only=false --files-changed-only=false --ignore=.github ``` +The default [`--tidy-checks`][tidy-checks] no longer adds the Clang Static Analyzer checks +(`clang-analyzer-*`), because they can make clang-tidy many times slower. clang-tidy 22 and newer +also leave them out of their own defaults, so with those versions they only run if a `.clang-tidy` +file or `--tidy-checks` enables them. clang-tidy 21 and older still enable them by default; add +`-clang-analyzer-*` to `--tidy-checks` to turn them off there. To keep them with any version, add +them back: + +```shell +cpp-linter --tidy-checks="boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*" +``` + ## Fixes are written to a patch In v1, `--fix` applied clang-format fixes in place, editing the files in the working tree.