I am integrating cppcheck in my project for static analysis of the code. I am using below command to perform analysis but not able to ignore the code from the directories provided with -i option.
Yes. It is correct without space. But --project option and -i option are not working together. I want to use --project and also want to ignore the unwanted code from some directories.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hmm.. is it possible for you to test latest cppcheck? When I try ./cppcheck -iexternals --project=lib/cppcheck.vcxproj then the files in externals are ignored. But I have a strong feeling that this did not work a month ago. It feels like this was fixed but I am not sure when that happened.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Daniel, I was facing this issue because I was providing relative path of the directory which I wanted to exclude. It is working if I provide absolute path.
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
<errorid="noExplicitConstructor"severity="style"msg="Class 'XMLDeclaration' has a constructor with 1 argument that is not explicit."verbose="Class 'XMLDeclaration' has a constructor with 1 argument that is not explicit. Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided."cwe="398"><locationfile0="lib\analyzerinfo.cpp"file="externals\tinyxml\tinyxml2.h"line="1073"column="5"/><symbol>XMLDeclaration</symbol></error>
What is the difference between file0 and file? In file appears externals, should this be there?
Daniel, do you think this might be related or do I miss something?
Best & thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The file0 specify what file is checked to get this error. This information is used in the GUI. If you generate a html report or text report then file0 is probably not interesting.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Maybe we can clarify it. Please feel free to suggest improvements.
If you run cppcheck like this: cppcheck -Ifoo -ifoo file1.cpp then if file1.cpp includes headers in foo then those headers will be included and analyzed and warnings will be written.
If you run cppcheck like this cppcheck -ifoo . then no source files in foo will be checked. For instance if there is a file "foo/1.cpp" then that file will not be checked. However if there is a file in the current path ./file1.cpp that contains #include "foo/1.h" then that header will be included and analyzed and you will get warnings.
So.. -i does not affect what files we include when there are #include directives in the code.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Examples are always great, would you have something agains including that example inside the --help string?
I would gladly open a PR, what do you think.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am integrating cppcheck in my project for static analysis of the code. I am using below command to perform analysis but not able to ignore the code from the directories provided with -i option.
Please help me to ignore code from these directories.
Regards,
Rohit
Did you try to insert a space between -i and the path to be ignored?
Yes. It is correct without space. But --project option and -i option are not working together. I want to use --project and also want to ignore the unwanted code from some directories.
There was a discussion in the chat that you missed. I think we should fix -i for 1.90.
We can reproduce this in the cppcheck repo with:
$ ./cppcheck -iexternals --project=lib/cppcheck.vcxproj
Hi Daniel, Any update on this issue? Any idea about release date of 1.90?
Somehow I forogt about it. I have created https://trac.cppcheck.net/ticket/9463 and intend to fix that.
My feeling right now is ~1 month. I can only give a rough guess.
Okay Daniel. Thank you for the update.
hmm.. is it possible for you to test latest cppcheck? When I try
./cppcheck -iexternals --project=lib/cppcheck.vcxproj
then the files in externals are ignored. But I have a strong feeling that this did not work a month ago. It feels like this was fixed but I am not sure when that happened.I tried cppcheck-1.89 now.. and that seems to ignore paths also. not sure how to reproduce the problem.
I close the ticket. I can't reproduce. If you still have problems.. it would be good if you can help us reproduce.
Hi Daniel, I was facing this issue because I was providing relative path of the directory which I wanted to exclude. It is working if I provide absolute path.
Thank you.
If I execute the following command with
cppcheck
compiled from7da68bff7b99e6d142591b30b0c25804a4a1da4a
CommitDate: Thu Dec 5 18:25:50 2019 +0300
I see lines like:
What is the difference between
file0
andfile
? Infile
appearsexternals
, should this be there?Daniel, do you think this might be related or do I miss something?
Best & thanks
The
file0
specify what file is checked to get this error. This information is used in the GUI. If you generate a html report or text report then file0 is probably not interesting.hmm.. the
-i
does not mean "suppress warnings in ..." nor "prevent #include for files in...".The
cppcheck --help
is not crystal clear:Maybe we can clarify it. Please feel free to suggest improvements.
If you run cppcheck like this:
cppcheck -Ifoo -ifoo file1.cpp
then if file1.cpp includes headers in foo then those headers will be included and analyzed and warnings will be written.If you run cppcheck like this
cppcheck -ifoo .
then no source files in foo will be checked. For instance if there is a file "foo/1.cpp" then that file will not be checked. However if there is a file in the current path ./file1.cpp that contains#include "foo/1.h"
then that header will be included and analyzed and you will get warnings.So..
-i
does not affect what files we include when there are#include
directives in the code.Examples are always great, would you have something agains including that example inside the
--help
string?I would gladly open a PR, what do you think.