The--suppress=unmatchedSuppression does not seem to work for the suppression with wildcard in the filename part.
If we have the following sources:
1. includeFaultyHeader.cpp => just containing #include "include/FaultyHeader.h
2. IncludeNothing.cpp => empty
3. include/FaultyHeader.h => class A{ A(int i){}} (or anything else reporting an error)
Case that works as I expect:
1. cppcheck --enable=all includeFaultyHeader.cpp => warning
2. cppcheck --enable=all IncludeNothing.cpp => no warning
3. cppcheck --enable=all --suppress=noExplicitConstructor includeFaultyHeader.cpp => no warning
4. cppcheck --enable=all --suppress=noExplicitConstructor IncludeNothing.cpp => warn for unmatched suppression
5. cppcheck --enable=all --suppress=noExplicitConstructor --suppress=unmatchedSuppression includeFaultyHeader.cpp => no warning
6. cppcheck --enable=all --suppress=noExplicitConstructor --suppress=unmatchedSuppression IncludeNothing.cpp => no warning
7. cppcheck --enable=all --suppress=*:include/FaultyHeader.h --suppress=unmatchedSuppression includeFaultyHeader.cpp => no warning
8. cppcheck --enable=all --suppress=*:include/FaultyHeader.h --suppress=unmatchedSuppression IncludeNothing.cpp => no warning
Case that don't work what I except:
1. cppcheck --enable=all --suppress=*:include/* --suppress=unmatchedSuppression IncludeNothing.cpp => warn for unmatched suppression, expecting no warning
2. cppcheck --enable=all --suppress=uselessAssignmentArg:include/* --suppress=unmatchedSuppression includeFaultyHeader.cpp => warn for unmatched suppression, expecting no warning
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.
Last edit: Lionel Gimbert 2019-12-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
Hello,
The
--suppress=unmatchedSuppression
does not seem to work for the suppression with wildcard in the filename part.If we have the following sources:
1. includeFaultyHeader.cpp => just containing
#include "include/FaultyHeader.h
2. IncludeNothing.cpp => empty
3. include/FaultyHeader.h =>
class A{ A(int i){}}
(or anything else reporting an error)Case that works as I expect:
1.
cppcheck --enable=all includeFaultyHeader.cpp
=> warning2.
cppcheck --enable=all IncludeNothing.cpp
=> no warning3.
cppcheck --enable=all --suppress=noExplicitConstructor includeFaultyHeader.cpp
=> no warning4.
cppcheck --enable=all --suppress=noExplicitConstructor IncludeNothing.cpp
=> warn for unmatched suppression5.
cppcheck --enable=all --suppress=noExplicitConstructor --suppress=unmatchedSuppression includeFaultyHeader.cpp
=> no warning6.
cppcheck --enable=all --suppress=noExplicitConstructor --suppress=unmatchedSuppression IncludeNothing.cpp
=> no warning7.
cppcheck --enable=all --suppress=*:include/FaultyHeader.h --suppress=unmatchedSuppression includeFaultyHeader.cpp
=> no warning8.
cppcheck --enable=all --suppress=*:include/FaultyHeader.h --suppress=unmatchedSuppression IncludeNothing.cpp
=> no warningCase that don't work what I except:
1.
cppcheck --enable=all --suppress=*:include/* --suppress=unmatchedSuppression IncludeNothing.cpp
=> warn for unmatched suppression, expecting no warning2.
cppcheck --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