I have been trying to get the MISRA addon to work in CppCheck and I keep getting "Failed to load misra.json". I've attached my CMD output. The first output is when I have misra.json in the CppCheck addons folder, and the second is when I moved misra.json into the folder that cmd is in. I also got the second cmd error when I changed --addons to the full path of misra.json and left it in the CppCheck addons folder.
In the GUI when I try to scan this directory with one test file in it with the MISRA addon, it will show the normal CppCheck errors but then completely crash and close.
I have attached screenshots of my misra.json and the Misra rules so you can see the format I used for that as well (edited out the rules themselves).
If you need more information let me know, hopefully this is an easy fix!
the problem with that is there is a space after the --rule-texts=. The filename should be specified directly. If you want to share more dumps can you please copy paste the text instead it's a bit clumpsy with the screenshots.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you use that "m.txt" file you should get different texts.
For your information if your company purchase the Cppcheck Premium license (https://www.cppchecksolutions.com), you don't need to configure the rules texts like this. The Cppcheck Premium provides proper misra rules texts.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for the information! I will consider a license.
I created the m.txt file but was unable to get a change in output. It still says "(use --rule-texts to get proper output)" for the rules that you had me put in the text file.
Last edit: Nolan Bridges 2022-06-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
[1.c:2] (style) misra violation 802 with no text in the supplied rule-texts-file (Undefined) [misra-c2012-8.2] [1.c:2] (style) misra violation 804 with no text in the supplied rule-texts-file (Undefined) [misra-c2012-8.4]
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
[1.c:1] (style) misra violation 802 with no text in the supplied rule-texts-file (Undefined) [misra-c2012-8.2][1.c:1] (style) misra violation 804 with no text in the supplied rule-texts-file (Undefined) [misra-c2012-8.4]Traceback (most recent call last):File "C:\Program Files\Cppcheck\addons\misra.py", line 4704, in <module>main()File "C:\Program Files\Cppcheck\addons\misra.py", line 4638, in mainchecker.parseDump(item)File "C:\Program Files\Cppcheck\addons\misra.py", line 4222, in parseDumpdata=cppcheckdata.parsedump(dumpfile)File "C:\Program Files\Cppcheck\addons\cppcheckdata.py", line 1220, in parsedumpreturn CppcheckData(filename)File "C:\Program Files\Cppcheck\addons\cppcheckdata.py", line 1026, in __init__for event, node in ElementTree.iterparse(self.filename, events=('start', 'end')):File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\xml\etree\ElementTree.py", line 1274, in iterparsenext(it)File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\xml\etree\ElementTree.py", line 1251, in iteratorsource=open(source, "rb")PermissionError: [Errno 13] Permission denied: '.'
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So I got the rules texts to work fine and the rule text displays next to the error, thank you so much for all of your help!
However, I would like to use the GUI to scan many files, but when running it, the severity only shows style for all of the MISRA violations, and not Advisory, Mandatory, or Required. Would you happen to know how to fix this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have been trying to get the MISRA addon to work in CppCheck and I keep getting "Failed to load misra.json". I've attached my CMD output. The first output is when I have misra.json in the CppCheck addons folder, and the second is when I moved misra.json into the folder that cmd is in. I also got the second cmd error when I changed --addons to the full path of misra.json and left it in the CppCheck addons folder.
In the GUI when I try to scan this directory with one test file in it with the MISRA addon, it will show the normal CppCheck errors but then completely crash and close.
I have attached screenshots of my misra.json and the Misra rules so you can see the format I used for that as well (edited out the rules themselves).
If you need more information let me know, hopefully this is an easy fix!
Best regards,
Nolan
Not sure. Looks correct to me. Can you test what happens if you put the rule texts file in another path that does not have spaces?
I moved the rule text file to another location without spaces and now I'm getting this error (see attached):
the problem with that is there is a space after the
--rule-texts=
. The filename should be specified directly. If you want to share more dumps can you please copy paste the text instead it's a bit clumpsy with the screenshots.Thank you for your response Daniel. That did work but now I'm getting this as output in my text file. This is an example of a few lines:
Any ideas? I've only removed that space so everything else is the same.
Thanks,
Nolan
Thank you for your response Daniel. That did work but now I'm getting this as output in my text file. This is an example of a few lines:
Any ideas? I've only removed that space so everything else is the same.
Thanks,
Nolan
Hmm. Obviously the misra rule texts does not work properly.
Can you write a "m.txt" file with this contents:
If you use that "m.txt" file you should get different texts.
For your information if your company purchase the Cppcheck Premium license (https://www.cppchecksolutions.com), you don't need to configure the rules texts like this. The Cppcheck Premium provides proper misra rules texts.
Thank you for the information! I will consider a license.
I created the m.txt file but was unable to get a change in output. It still says "(use --rule-texts to get proper output)" for the rules that you had me put in the text file.
Last edit: Nolan Bridges 2022-06-21
More basic then.
Source code:
Put that in file "1.c".
Commands:
I expect some such output:
[1.c:2] (style) misra violation 802 with no text in the supplied rule-texts-file (Undefined) [misra-c2012-8.2]
[1.c:2] (style) misra violation 804 with no text in the supplied rule-texts-file (Undefined) [misra-c2012-8.4]
I ran that and this is the output I received:
Update: Yes, it was the " . " in the command that was causing the traceback, I think I got the rule text working, I just need to reformat everything.
I'm running this command after the cppcheck dump command, maybe the " . " in the command before the "2" is causing the error?
Last edit: Nolan Bridges 2022-06-23
So I got the rules texts to work fine and the rule text displays next to the error, thank you so much for all of your help!
However, I would like to use the GUI to scan many files, but when running it, the severity only shows style for all of the MISRA violations, and not Advisory, Mandatory, or Required. Would you happen to know how to fix this?