I wish to use cppcheck on a per commit basis on our CI but I'm hitting a few hurdles.
when using a compile_command.json as the project file I am unable to check indivuidule files covered by the commit it forces the checking of the whole codebase.
I have tried to cut down the compile_command.json file to only include the files with in the commit but in this instance it finds very few errors including ones given in a rule file which it does find with out the project file. These are scoping errors ect and not ones to do with unused functions.
Any advice would be very helpful.
Last edit: Robert Killingsworth 2020-02-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmm, I am not aware of such a functionality in Cppcheck itself. I am not sure if only analysing the changed files could miss any errors, so I would always run a full analysis and compare the results.
What also comes to my mind is using --cppcheck-build-dir=.
From the help:
--cppcheck-build-dir=<dir>Analysisoutputdirectory. Usefulforvariousdata.
Somepossibleusagesare; whole program analysis,incrementalanalysis, distributedanalysis.
I am not sure if the incremental analysis that is mentioned here works as you need it.
Cppcheck stores information about the code in the specified directory (which must exist already IIRC). If you do not delete this content it can be reused during the next analysis.
Maybe you could give it a try.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I wish to use cppcheck on a per commit basis on our CI but I'm hitting a few hurdles.
when using a compile_command.json as the project file I am unable to check indivuidule files covered by the commit it forces the checking of the whole codebase.
I have tried to cut down the compile_command.json file to only include the files with in the commit but in this instance it finds very few errors including ones given in a rule file which it does find with out the project file. These are scoping errors ect and not ones to do with unused functions.
Any advice would be very helpful.
Last edit: Robert Killingsworth 2020-02-27
Hmm, I am not aware of such a functionality in Cppcheck itself. I am not sure if only analysing the changed files could miss any errors, so I would always run a full analysis and compare the results.
What also comes to my mind is using
--cppcheck-build-dir=
.From the help:
I am not sure if the
incremental analysis
that is mentioned here works as you need it.Cppcheck stores information about the code in the specified directory (which must exist already IIRC). If you do not delete this content it can be reused during the next analysis.
Maybe you could give it a try.
How much do you check run time characteristics for advanced source code analyses?