Open whisperity opened 5 years ago
Hi, I support this request as it would fix use cases when legacy / 3rd pty library is used and even if there was chance to refactor, it would take too much time, compared to original commit, it would be easier to whitelist for time, a single or multiple checks. So the outcome now usually to disable that check for entire project which is opposite of what we actually want.
Currently, the
// codechecker_suppress
mechanics only allow suppressing a report at a particular location. Sometimes, multiple reports of the almost exact same kind, for the exact same reason, can be present multiple times in the same file.One striking example might be GoogleTest's way of initialising the test type and code via a macro.
See this case snippet:
I'm not sure if suppressing all these reports via a line above
TEST(...)
is possible, but even if it is, it'd be really annoying to keep copying these lines.A better solution seems to be to allow suppressing a report for the entire file. Granular scripts which call different
CodeChecker analyze
calls for parts of the project could be a solution here, but that would be immensely hard to maintain.The above example is from JetBrains' CLion which has a built-in Clang-Tidy invoker and report shower. Clicking on
More options...
shows a button where a lot of configuration shows up, one of which is labelledDisable "cert-err58-cpp" for file
. CLion automatically reformats the file to add a few#pragma
lines and configuration which are not ever picked up by the compiler during compilation, but is either "parsed" via the IDE, or by Clang-Tidy itself to not show this particular warning.(I'm leaning more on the "parsed by IDE" side, as calling Clang-Tidy on a file with these extra pragmas in still results in the report shown when viewed via CodeChecker.)
Note
TEST
not being underlined anymore:Perhaps
// codechecker_suppress
could be extended so that it may appear somewhere in a file, marking that reports that end in the said file should all be considered ignored (with optional comment, etc. as the usual feature set.) For example, I'd be happy to preamble all my test files (could even set an IDE template so when I create a new C++ Test source file it is inserted automatically) with this:Another idea that could be considered for suppressions is how Clang Format works: you can put
// clang-format off
// clang-format on
markers in the code, and between theoff
andon
part, the formatting does not touch your code, even if it is badly formatted. Similar could be done with suppressions, if one might wants to ignore an entire code block – however, this is not appropriate here: I only want to not care about the static initialisation yadda for the test class bodies, I'd still be happy to see other kinds of issues that might be present in the test codes I've written.