-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow specifying the Checks as a list in the yaml config file #51428
Comments
(Side note: of course this highlights another issue, namely that NOLINT should also check for aliases when deciding whether to silence a diagnostic?) |
That would indeed be nice. The aliases also have the problem that it's not too clear from the docs how they work. I don't think the following question has an answer in the docs: Is clang-tidy --checks='-*,hicpp-avoid-goto,cppcoreguidelines-avoid-goto' test.cpp going to take double the time than clang-tidy --checks='-*,cppcoreguidelines-avoid-goto' test.cpp to do the exact same work? By measuring the wall time of both commands with a (too small to create reliable measurements) test file I would say the answer is no, that clang-tidy is smart enough to notice they are the same and only does the check once. But if I ask --enable-check-profile clang-tidy --checks='-*,hicpp-avoid-goto,cppcoreguidelines-avoid-goto' --enable-check-profile test.cpp I get things like ===-------------------------------------------------------------------------=== ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- Which seem to suggest the aliased checks slows down the process, at least a bit. |
I would also like this. At my work, we've grown a homemade wrapper of clang-tidy that parses a yaml file supporting Note that the following would work: Checks: >-
*,
-some-alias, but we also want to add some comments in there, and that's not possible whereas it can be done if |
It is certainly possible to have a list-like with interleaved comments:
The trick is that the comment must end with a comma. Arguably not the most readable/maintainable though. |
Patch up for review: https://reviews.llvm.org/D147876 |
Specifying checks as a string is convenient for quickly using clang-tidy to run a handful of checks. However it is not suitable for projects that have a long list of enabled or disabled checks. It is specially troublesome in case one wants to interleave comments with the checks, to explain why they are enabled or disabled. Currently this can be achieved via multiline strings in YAML, but it's error-prone. For example, comments must end with a comma for clang-tidy to continue processing the list of globs; a missing comma will make clang-tidy silently ignore the rest of the list. Instead, enable passing a native YAML list to the "Checks" option in the config file. The implementation is done such that the old behavior is kept: a user can pass a string or a list. We can consider deprecating passing the checks as a string altogether in a future release, to simplify the internal logic of the YAML parser. Fixes llvm#51428 Differential Revision: https://reviews.llvm.org/D147876
Specifying checks as a string is convenient for quickly using clang-tidy to run a handful of checks. However it is not suitable for projects that have a long list of enabled or disabled checks. It is specially troublesome in case one wants to interleave comments with the checks, to explain why they are enabled or disabled. Currently this can be achieved via multiline strings in YAML, but it's error-prone. For example, comments must end with a comma for clang-tidy to continue processing the list of globs; a missing comma will make clang-tidy silently ignore the rest of the list. Instead, enable passing a native YAML list to the "Checks" option in the config file. The implementation is done such that the old behavior is kept: a user can pass a string or a list. We can consider deprecating passing the checks as a string altogether in a future release, to simplify the internal logic of the YAML parser. Fixes llvm#51428 Differential Revision: https://reviews.llvm.org/D147876
Extended Description
Let's say I want to say:
Currently I can do
Checks: 'hicpp-,cppcoreguidelines-,-cppcoreguidelines-narrowing-conversions,-hicpp-avoid-goto'
...
but it's not clear cppcoreguidelines-narrowing-conversions and hicpp-avoid-goto have been disable for very different reasons. I could add a comment before "Checks", but that doesn't work too well when the list gets longer.
As far as I know there is no way to include comments interleaving a YAML string. So it would be nice if "Checks" could be expressed also as a list, so
Checks:
I don't like it
Duplicate of cppcoreguidelines-avoid-goto
...
could be used.
The text was updated successfully, but these errors were encountered: