clangclang-tidy

Clang-Tidy `NOLINT` for multiple lines?


I'm working on a C++ project that has some large sections of code that are autogenerated, and I don't want to be linted. Is there something akin to the //NOLINT comment that can be applied to multiple lines? Like the following:

// BEGINNOLINT
bad-code;
// ENDNOLINT

All I could find online was a suggestion that this should be implemented. Is there any way to avoid having to write // NOLINT on the end of every single line?


Solution

  • clang-tidy 14 introduced this feature:

    // NOLINTBEGIN
    ...
    // NOLINTEND
    

    Note, if you want to disable a specific warning, the end-comment must match the begin-comment:

    // NOLINTBEGIN(check-name)
    ...
    // NOLINTEND(check-name)