Reputation: 2767
Is there a way to selectively disable clang-tidy warnings. For example, I have readability-identifier-naming
checks enabled, and also display warnings inside header through header-filter
. All methods are checked if they are in CamelCase. However, there are occasionally classes that are to be drop-in replacement of another STD class or Boost class and thus they have the lower case naming convention. In this case, clang-tidy emits a lot of warnings. Is there a way to disable them for specific segment of codes. Similar to the effect of // clang-format off
and // clang-format on
for clang-format.
Upvotes: 3
Views: 6781
Reputation: 101
There are several ways to do this:
// NOLINT
at the end of line you want to skip.
// NOLINTNEXTLINE(readability-identifier-naming)
before that line to skip only "readability-identifier-naming" checks.
Run clang-tidy with parameter
-line-filter='[{"name":"myprog.cpp","lines":[[1,99],[101,200]]}]'
Line 100 will be skipped in this example.
The third way allows to skip more than one line, but is inconvenient when the source file is frequently changing (you'll need to change line numbers every time you modify the source).
Possible duplicate of this question.
Upvotes: 5