I try to run a cppcheck analysis over my code, which has the following file structure:
/code/module_1/src/a.cpp
/code/module_1/src/b.cpp
/code/module_1/test/c.cpp
/code/module_2/src/d.cpp
/code/module_2/src/e.cpp
/code/module_3/test/f.cpp
I'd like to run an analysis excluding all test code. Is this possible with a command like "cppcheck -itest"? It doesn't work for me, although I think it should, according to the docs:
...Directory name is matched to all parts of the path.
I'm using version 1.69. I know I could mention all test directories separately (which does work, I checked), but the number of modules is too high to do this for many analyses reasonably.
Is this possible?
I installed Cppcheck to do some tests and it seems the -i
implementation is a bit bonkers. However, I managed to achieve what you want.
Solution: use -itest\
instead of -itest
(this was in Windows; maybe Linux needs -itest/
)
Rationale: in my tests, -itest
worked only if there was a .\test\
directory, in which case even .\a\test\a.cpp
was excluded. With -itest\
, however, such exclusion took place regardless of the presence of .\test\
directory.
This seems like a bug which the developers ought to weed out, but, in the meantime, you can succeed using the above workaround.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With