简体   繁体   中英

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-*,'
...

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).

You can also use the back slash at the end of every line:

---
Checks: "-*,\
modernize-*,\
-modernize-use-trailing-return-type,\
misc-*,\
-misc-non-private-member-variables-in-classes,\
-misc-no-recursion,\
cppcoreguidelines-*,\
"
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM