Search code examples
c++clang-tidy

Clang-tidy file: How to list the checks in multiple lines


Right now I have a .clang-tidy file that includes a large list of checks and they all go in one line like this:

Checks: '-*,bugprone-*,-bugprone-narrowing-conversions, cert-*, -cert-err58-cpp, clang-analyzer-*,cppcoreguidelines-*,-cppcoreguidelines-narrowing-conversions...'

Is there a way to list each check (enabled or disabled) in multiple lines for easier version control?

Right now I toggle word wrap and that helps editing, but it's very hard to diff in code reviews.

I'm looking for something like this:

Checks:
'-*,'
'cert-*,etc-*,'
...

Solution

  • You can remove the single quotation marks and list all checks in a line-breaking comma separated list that starts with a > entry, constructing a .clang-tidy file as follows:

    ---
    Checks: >
        -*,
        cert-*,
        etc-*,
        <additional checks ...>
    ...
    

    As of D30567: [clang-tidy] Fix treating non-space whitespaces in checks list the leading whitespace on each new line are only for readability, and you may choose any consistent number of leading spaces (YAML).