[PATCH] D96281: [clang-tidy] Add options to flag individual core increments and to ignore macros to readability-function-cognitive-complexity check.
Vivien Geoffroy via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 2 08:42:18 PST 2021
vgeof added a comment.
I just wanted to upvote the Macro parameter addition !
In my team, we use macros for logging purpose. We don't have access to their implementations, and they all have (sadly) a high complexity score.
So we write a lot of functions like this one, which in my opinion *should* have a low complexity:
bool doStuff(myClass* objectPtr){
if(objectPtr == nullptr){
LOG_WARNING("empty object");
return false;
}
if(objectPtr->getAttribute() == nullptr){
LOG_WARNING("empty object");
return false;
}
use(objectPtr->getAttribute());
}
and clang-tidy report all of our functions because LOG_WARNING has a complexity of 12 in itself, so I had to disable the whole checker.
If I could disable macros accounting in the complexity score, I could enable the checker again(which I find awesome by the way) !
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96281/new/
https://reviews.llvm.org/D96281
More information about the cfe-commits
mailing list