Using Cppcheck addons
Currently there are two steps to use an addon:
1. Run Cppcheck to generate dump files
2. Run the addon on the dump files
The --dump flag is used to generate dump files. To generate a dump file for every source file in the
foo/ folder:
cppcheck --dump foo/
To run a addon script on all dump files in the foo/ folder:
python addon.py foo/*.dump
To suppress a MISRA rule, use:
python misra.py --suppress-rules 15.1,11.3,20.13 ...
You were using cppcheck directly on the dump files.
Only parsing the suppressed rules uses:
^(misra|MISRA)_._.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I never did any testing with inline suppressions. Let me know if they don't work and I'll see if I can figure out why.
Note the above rule (misra-c2012-16.1) will not be parsed corrected by the misra.py code as the rule number needs to be immediately after the 'misra' prefix.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the testing. I'm not sure when I'll have time to look at this. Do you know any python? You can use the --show-suppressed-rules argument to misra.py to make it dump the parsed suppression list.
To check the incomming items from the dump file you will have to add some debugging to the parseSuppressions() method. You will need to print out the values coming in from
for each in self.dumpfileSuppressions
And then debug if the parser is not pickingup the inline suppression values correctly.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the gui, with the "enable inline suppressions" checked, I still see both errors reported.
The xml results look like this (I redacted the rules text manually):
<?xml version="1.0" encoding="UTF-8"?><resultsversion="2"><cppcheckversion="1.90"/><errors><errorid="unmatchedSuppression"severity="information"msg="Unmatched suppression: misra-c2012-15.5"verbose="Unmatched suppression: misra-c2012-15.5"sinceDate="5/13/2020"><locationfile="cppcheck-test\test.cpp"line="5"/></error><errorid="unmatchedSuppression"severity="information"msg="Unmatched suppression: misra-c2012-15.5"verbose="Unmatched suppression: misra-c2012-15.5"sinceDate="5/13/2020"><locationfile="cppcheck-test\test.cpp"line="8"/></error><errorid="misra-c2012-15.5"severity="style"msg=""verbose=""sinceDate="5/13/2020"><locationfile="cppcheck-test\test.cpp"line="5"/></error><errorid="misra-c2012-15.5"severity="style"msg=""verbose=""sinceDate="5/13/2020"><locationfile="cppcheck-test\test.cpp"line="8"/></error><errorid="unusedFunction"severity="style"msg="The function &#039;f&#039; is never used."verbose="The function &#039;f&#039; is never used."sinceDate="5/13/2020"><locationfile="cppcheck-test\test.cpp"line="1"/></error></errors></results>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would like to inquire how to perform inline code suppressions for MISRA rules when using misra.py on a dump file?
I tried the following but the suppressions are not added in the "Suppressed Rules List":
// cppcheck-suppress 15.6
// cppcheck-suppress MISRA_15.6
// cppcheck-suppress misra_15.6
// cppcheck-suppress MISRA_15_6
// cppcheck-suppress MISRA.15.6
The manual says to do the following:
Using Cppcheck addons
Currently there are two steps to use an addon:
1. Run Cppcheck to generate dump files
2. Run the addon on the dump files
The --dump flag is used to generate dump files. To generate a dump file for every source file in the
foo/ folder:
cppcheck --dump foo/
To run a addon script on all dump files in the foo/ folder:
python addon.py foo/*.dump
To suppress a MISRA rule, use:
python misra.py --suppress-rules 15.1,11.3,20.13 ...
You were using cppcheck directly on the dump files.
Only parsing the suppressed rules uses:
^(misra|MISRA)_._.
I am not sure. Maybe inline suppressions are not added in the dump file. That is not by intention.
I created https://trac.cppcheck.net/ticket/8804
it seems to work for me. I tried with:
when the dump file is generated you need to use
--inline-suppr
.I never did any testing with inline suppressions. Let me know if they don't work and I'll see if I can figure out why.
Note the above rule (misra-c2012-16.1) will not be parsed corrected by the misra.py code as the rule number needs to be immediately after the 'misra' prefix.
I think the inline suppress for MISRA rules isn't working. Is it? Not finding a way to have a given MISRA rule to be suppressed on a given code line.
Im' on https://github.com/danmar/cppcheck/commit/862c4ef87b109ae86c2d5f12769b7c8d199f35c5
Thanks for the testing. I'm not sure when I'll have time to look at this. Do you know any python? You can use the --show-suppressed-rules argument to misra.py to make it dump the parsed suppression list.
To check the incomming items from the dump file you will have to add some debugging to the parseSuppressions() method. You will need to print out the values coming in from
for each in self.dumpfileSuppressions
And then debug if the parser is not pickingup the inline suppression values correctly.
yes, I can attempt some debug when I'll have some time. Thanks for the hints on where to look.
This issue is still present in v1.90.
For example, I can induce misra-c2012-15.5:
In the gui, with the "enable inline suppressions" checked, I still see both errors reported.
The xml results look like this (I redacted the rules text manually):
Thanks! I created this trac ticket: https://trac.cppcheck.net/ticket/9723