Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

clang-tidy

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-*,'
...
like image 546
Darien Pardinas Avatar asked Mar 17 '20 13:03

Darien Pardinas


People also ask

What is clang-tidy check?

Clang-tidy is a standalone linter tool for checking C and C++ source code files.

How do I run clang-tidy on folder?

Run clang-tidy on you entire codebaseIn the build folder, run run-clang-tidy . It might be a different command ( run-clang-tidy.py or run-clang-tidy-VERSIONNUMBER ) depending on your distro's packaging preference.

What is clang-tidy checks Android studio?

Clang-Tidy is a Clang-based tool for static code analysis. CLion shows Clang-Tidy checks the same way as its own code inspections, with quick-fixes available via the -button or Alt+Enter : Gif.


1 Answers

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

like image 164
dfrib Avatar answered Sep 28 '22 07:09

dfrib