Hello,
The--suppress=unmatchedSuppression does not seem to work for the suppression with wildcard in the filename part.
--suppress=unmatchedSuppression
If we have the following sources:
#include "include/FaultyHeader.h
class A{ A(int i){}}
Case that works as I expect:
cppcheck --enable=all includeFaultyHeader.cpp
cppcheck --enable=all IncludeNothing.cpp
cppcheck --enable=all --suppress=noExplicitConstructor includeFaultyHeader.cpp
cppcheck --enable=all --suppress=noExplicitConstructor IncludeNothing.cpp
cppcheck --enable=all --suppress=noExplicitConstructor --suppress=unmatchedSuppression includeFaultyHeader.cpp
cppcheck --enable=all --suppress=noExplicitConstructor --suppress=unmatchedSuppression IncludeNothing.cpp
cppcheck --enable=all --suppress=*:include/FaultyHeader.h --suppress=unmatchedSuppression includeFaultyHeader.cpp
cppcheck --enable=all --suppress=*:include/FaultyHeader.h --suppress=unmatchedSuppression IncludeNothing.cpp
Case that don't work what I except:
cppcheck --enable=all --suppress=*:include/* --suppress=unmatchedSuppression IncludeNothing.cpp
cppcheck --enable=all --suppress=uselessAssignmentArg:include/* --suppress=unmatchedSuppression includeFaultyHeader.cpp
So the issue seams to be due to the wild card in the filename.
I take a quick look at how cppcheck source code handle the unmatched suppression but havn't figured anything obvious.
I have reproduced it (thanks for the detailed report, it was no problem) and I found something. The interesting place is here: https://github.com/danmar/cppcheck/blob/0507b1a2b62eb095871606adfcafa9c210aaa971/lib/errorlogger.cpp#L565 Debugging through this loop shows that this should work (note the :* after unmatchedSuppression):
:*
unmatchedSuppression
cppcheck --enable=all --suppress=*:include/* --suppress=unmatchedSuppression:* IncludeNothing.cpp
while this does not work (as you wrote):
The loop only tests for global suppressions where the filename matches or where filename is set to *. Maybe an empty filename should be handled the same as a *. IMHO that would make sense, if nothing is specified, everything should match I guess.
*
Edit: I created a PR that would fix this issue.
I have reproduced it (thanks for the detailed report, it was no problem)
As a dev I know the pain of bug report without clear reproducing step ;)
Great news! Thanks
Log in to post a comment.
Hello,
The
--suppress=unmatchedSuppressiondoes not seem to work for the suppression with wildcard in the filename part.If we have the following sources:
#include "include/FaultyHeader.hclass A{ A(int i){}}(or anything else reporting an error)Case that works as I expect:
cppcheck --enable=all includeFaultyHeader.cpp=> warningcppcheck --enable=all IncludeNothing.cpp=> no warningcppcheck --enable=all --suppress=noExplicitConstructor includeFaultyHeader.cpp=> no warningcppcheck --enable=all --suppress=noExplicitConstructor IncludeNothing.cpp=> warn for unmatched suppressioncppcheck --enable=all --suppress=noExplicitConstructor --suppress=unmatchedSuppression includeFaultyHeader.cpp=> no warningcppcheck --enable=all --suppress=noExplicitConstructor --suppress=unmatchedSuppression IncludeNothing.cpp=> no warningcppcheck --enable=all --suppress=*:include/FaultyHeader.h --suppress=unmatchedSuppression includeFaultyHeader.cpp=> no warningcppcheck --enable=all --suppress=*:include/FaultyHeader.h --suppress=unmatchedSuppression IncludeNothing.cpp=> no warningCase that don't work what I except:
cppcheck --enable=all --suppress=*:include/* --suppress=unmatchedSuppression IncludeNothing.cpp=> warn for unmatched suppression, expecting no warningcppcheck --enable=all --suppress=uselessAssignmentArg:include/* --suppress=unmatchedSuppression includeFaultyHeader.cpp=> warn for unmatched suppression, expecting no warningSo the issue seams to be due to the wild card in the filename.
I take a quick look at how cppcheck source code handle the unmatched suppression but havn't figured anything obvious.
Last edit: Lionel Gimbert 2019-12-06
I have reproduced it (thanks for the detailed report, it was no problem) and I found something.
The interesting place is here: https://github.com/danmar/cppcheck/blob/0507b1a2b62eb095871606adfcafa9c210aaa971/lib/errorlogger.cpp#L565
Debugging through this loop shows that this should work (note the
:*afterunmatchedSuppression):while this does not work (as you wrote):
The loop only tests for global suppressions where the filename matches or where filename is set to
*. Maybe an empty filename should be handled the same as a*. IMHO that would make sense, if nothing is specified, everything should match I guess.Edit: I created a PR that would fix this issue.
Last edit: versat 2019-12-09
As a dev I know the pain of bug report without clear reproducing step ;)
Great news! Thanks