Background
The list of Enabled/Disabled checks for clang-tidy might be defined in a .clang-tidy config file, for example:
Checks: '*,-llvm*,-cppcoreguidelines-avoid-const-or-ref-data-members,*'
Also, there is a corresponding setting in settings:
- ReSharper | Options | Code Editing | C/C++ | Clang-Tidy;
- Rider | File | Settings | Languages & Frameworks | C++ | Clang-Tidy;
"List of enabled/disabled clang-tidy checks:" with the default value set to *
Question
It seems that for the list of checks set in .clang-tidy file to start working, the default setting List of enabled/disabled clang-tidy checks: needs to be changed manually from '*' to ' ' (empty string).
Answer
That is true and is by design. ReSharper++ (backend for Rider C++) does not write its own .clang-tidy config (so that a user-provided one can be picked), and passes the list of checks via the –checks command line option, which gets appended to the checks option from .clang-tidy. R++ constructs –checks argument by taking "List of enabled/disabled clang-tidy checks" and appending to it the names of checks which are turned off in R++ (on the "Inspection Severity" options page). That means that if one wants to use the value of checks from the config file, one need to set "List of enabled/disabled clang-tidy checks" to an empty string and turn on inspections that one is interested in (some inspections are off by default because R++ has their counterparts or inspections are too noisy).
Clang-tidy config is looked up by clang-tidy itself in the closest parent directory of the source file. The source file here is (as with the rest of R++ inspections) the .cpp file if the analysis is run on a .cpp, or a random .cpp file which includes the header when the analysis is performed on a header file.
We have a corresponding feature request to improve this behavior: RSCPP-30593 Provide a convenient way to use the checks list from .clang-tidy
Comments
0 comments
Please sign in to leave a comment.