I'm having trouble using "--rule-texts" to add my MISRA C rules. I've tried the GUI and the command line. What am I doing wrong? Here's my command line: CMD> cppcheck --addon=misra.py --rule-texts=<misra_rules_dummy.txt> main.c dump>MyOutput.txt
error: unrecognized command line option: "--rule-texts=". results in MyOutput.txt
Last edit: jfix-preco 2020-06-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Awesome! Thanks. I still get many messages that say something like this: "misra violation <use --rule-texts to get proper output>". Could that mean my rules are incomplete? They are from 2004.
Last edit: jfix-preco 2020-06-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm still struggling with this. I get the same resutls with the cmd line as I do with the GUI. I inserted some code that I know violates a MISRA rule and Cppcheck does not flag them. I've inserted this into my code:
I checked with your config and the rules file and it works for me, but there is one problem. The rules are numbered differently in MISRA 2004 and MISRA 2012. For example, these rules about switch statements has numbers 16.3 and 16.4 respectively.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am like a fish out of water when it comes to the command line. Would you mind sharing what you entered in the command line? I use this: cppcheck --addon=misra.json main.c
Would you mind sharing what you entered in the command line? I use this: cppcheck --addon=misra.json main.c
Yes, that's right, I use it the same way.
The problem is in your rule texts file. For some reason, you have the following string on the top of the rules file: Appendex A Summary of guidelines. But the MISRA addon is waiting for Appendix A line here.
After fixing this typo, MISRA addon works as expected:
But it still gives out incorrect numbers for the MISRA rules, because the 2004 and 2012 standards are different. I corrected your rules file and sent you to PM, please check it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I get the error "cppcheck: error: unrecognized command line option: "--addon=misra.json" when I execute the following command "cppcheck --enable=all --addon=misra.json --xml ./ 2> report.xml"
I'm having trouble using "--rule-texts" to add my MISRA C rules. I've tried the GUI and the command line. What am I doing wrong? Here's my command line:
CMD> cppcheck --addon=misra.py --rule-texts=<misra_rules_dummy.txt> main.c dump>MyOutput.txt
error: unrecognized command line option: "--rule-texts=". results in MyOutput.txt
Last edit: jfix-preco 2020-06-11
Hello,
You need to write a json file with addon settings as described in cppcheck manual (see chapter 9.2 Running Addons).
For example, you can create file
misra.json
with the following content:And call cppcheck by this way:
cppcheck --addon=misra.json main.c
Awesome! Thanks. I still get many messages that say something like this:
"misra violation <use --rule-texts to get proper output>".
Could that mean my rules are incomplete? They are from 2004.Last edit: jfix-preco 2020-06-11
Yes, it is quite possible. Please check that your rules texts file match the structure of this file:
https://github.com/danmar/cppcheck/blob/master/addons/test/misra/misra_rules_dummy.txt
You may also need to complete the texts of the missing rules.
I'm still struggling with this. I get the same resutls with the cmd line as I do with the GUI. I inserted some code that I know violates a MISRA rule and Cppcheck does not flag them. I've inserted this into my code:
/~~~
~~~
I checked with your config and the rules file and it works for me, but there is one problem. The rules are numbered differently in MISRA 2004 and MISRA 2012. For example, these rules about switch statements has numbers 16.3 and 16.4 respectively.
Are you using the command line or the GUI?
I used the command line.
I am like a fish out of water when it comes to the command line. Would you mind sharing what you entered in the command line? I use this: cppcheck --addon=misra.json main.c
Last edit: jfix-preco 2020-06-11
Yes, that's right, I use it the same way.
The problem is in your rule texts file. For some reason, you have the following string on the top of the rules file:
Appendex A Summary of guidelines
. But the MISRA addon is waiting forAppendix A
line here.After fixing this typo, MISRA addon works as expected:
But it still gives out incorrect numbers for the MISRA rules, because the 2004 and 2012 standards are different. I corrected your rules file and sent you to PM, please check it.
Last edit: Joanes Aizpuru 2023-04-25
Thank you so much! Your help has been invaluable. It is now working for me at the cmd line and with a GUI project. Thanks again!
I get the error "cppcheck: error: unrecognized command line option: "--addon=misra.json" when I execute the following command
"cppcheck --enable=all --addon=misra.json --xml ./ 2> report.xml"
Here is the contents of my misra.json file,
{
"script": "misra.py",
"args":
"--rule-texts=misra_rules.txt",
}
Could you plesse let me know whats the issue here?
Hello,
What version of Cppcheck are you using?
You also should correct syntax for JSON list in your misra.json:
Hello,
Thanks for the response.
I am using cppcheck version 1.86. Yes I corrected the error in JSON.
Last edit: freecoder 2020-09-11
The --addon option was added in Cppcheck 1.88 (see release notes). You should update Cppcheck, or call addon script directly, for example:
Thanks for the clarification Georgy.