Open srpgilles opened 2 months ago
Thanks for the ticket!
Unfortunately, the design of clang-tidy is based on the philosophy that checks are independent of each other. As a check author, it's impossible to foresee all the interconnections between all the 400+ checks. Adding dependencies between checks makes the codebase harder to maintain in the future and creates developer surprise.
So the advice when performing fix-its would be to run clang-tidy one check at a time in case they run into conflicts like in this case.
I understand completely.
Is it not possible to at the very least add a warning on the documentation pages of modernize-use-trailing-return-type
and readability-make-member-function-const
to warn against this possible conflict? (the modernize-use-trailing-return-type page already provides a "known limitation" paragraph)
By the way thanks a lot to all check authors for these incredible documentation pages, which are really helpful to set up correctly clang-tidy!
Absolutely, that's definitely possible! Thanks for the suggestion
I wrote for a quick lecture to introduce clang-tidy to my colleagues a faulty C++ snippet upon which I intended to run clang-tidy:
I discovered however on this simple example that
modernize-use-trailing-return-type
andreadability-make-member-function-const
are at odds:will yield for
ComputeArea()
the signature:which is not what is intended (and of course
clang-tidy
still complains about the missingconst
).There are of course workarounds if we want the two checks enabled:
clang-tidy
command fix twice. We end up withwhich is a bit more bloated that it should be (and trigger the compiler warning
clang-diagnostic-ignored-qualifiers
).clang-tidy
first without themodernize-use-trailing-return-type
, and then run it with this check.It would be better of course if this was handled properly automatically, hence this ticket!