Search code examples
clang-tidy

clang-tidy: Blacklist some checks (or regex for checks)


I agree with the majority of the clang-tidy checks, but some I don't see tremendous value in. Mostly these are the fuschia* checks, such as the default argument warnings:

error: calling a function that uses a default argument is disallowed [fuchsia-default-arguments...

Therefore I would like to know how to run all of the checks except the fuschia ones. Right now, I just check everything in Cmake:

set(CMAKE_CXX_CLANG_TIDY
        clang-tidy;
        -header-filter=.;
        -checks=*;
        -warnings-as-errors=*;)

Solution

  • Clang-tidy allows you to use positive and negative globs in specifying checks. Just use - as a prefix when specifying checks you want to exclude. In your case:

    -checks=*,-fuchsia*;
    

    If you want to verify which checks are enabled you can run a command:

    $ clang-tidy -checks=*,-fuchsia* -list-checks