Maybe there is a problem with the file encoding that avoids reading the rule texts.
See this ticket for more details: https://trac.cppcheck.net/ticket/8946
There are some special characters in the PDF and depending on the OS, editor and so on this results in differently encoded rule texts files which may or may not work well.
With the next release of Cppcheck an updated misra addon is delivered that will hopefully address this issue. At least for some widespread encodings.
You can try copying such a character into the file that works and check if it still works. Would be interesting if it has to do with this.
Ah I see, that makes sense.
I tried to edid the misra.py file with the suggested solutions but it does not help. Maybe I should try Python 2, because I use 3.7.1 at the moment
Edid:
I had a closer look at the used encoding and found some problems there. After adjusting the file with correct tabs and whitespaces it worked!
Thanks for your help :-)
Last edit: Michael Fuchs 2019-02-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So tabs/whitespaces were a problem? Do you think that this could/should be handled by the script in any better way? If that is something more users could experience i guess it would make sense to handle it.
If you have a dummy file that should work but does not i would appreciate if you can share it (without any rule texts, just some lines that show the problem).
We really should avoid to frustrate the users with such problems if it is possible :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I've created dump files for a library code using ./cppcheck --dump /home/myproject/Baseframework/
This checked for c files recursively and created dump files.
But when i tried this python misra.py --rule-texts=output.txt /home/myproject/Baseframework/ * .dump
It throws error like IOError: [Errno 2] Is a directory: /home/myproject/Baseframework/
How can i able to check multiple files in a directory using this script ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to integrate addons into cppcheck better so it will be easier to run them. Latest cppcheck development snapshot has a --addon option. Instead of:
To use that you'll need to have a misra.json file also.. that will just say which addon script you want to run (misra.py) and what additional parameters you want to have (--rule-texts=output.txt).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm running cppcheck in windows platform.
I've added misra rules in the gui and enabled the addon in my project(cppcheck) .
but the output wasn't showing any misra violations.
I tested the GUI and saw a similar problem. This feels like a severe bug. :-( I have fixed that in git HEAD. If you can test it also I would appreciate..
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
make MATCHCOMPILER=yes CFGDIR=cfg HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function"
make for gui
cd gui/
qmake HAVE_RULES=yes
make
and ran cppcheck
./cppcheck-gui
it has thrown this message Gtk-Message: Failed to load module "overlay-scrollbar"
and in gui it shown
failed to load cfg "std.cfg"
your cppcheck installation is broken...
and it doesn't showing any misra violations.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you please try to fix the failed to load cfg "std.cfg" message. This might work:
cd gui
./cppcheck-gui --data-dir=/home/youruser/cppcheck/cfg
I am not sure if the dump files are generated properly otherwise.
The reason misra does not work is not obvious. I guess it could be some parsing problem of the rule texts. Could you try some other addon first, such as the CERT? If CERT does not work then you have some general problem with addons.
In the cppcheck build folder (see your project file settings) you should see some "...dump-misra-results" files ... do you see those?
is this link has updated cppcheck (for windows 32)
That should have the latest release 1.88.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I'm trying to integrate cppcheck with eclipse.
i've done this so far
Click on Help->Install New Software...
Add the new Update Site https://dl.bintray.com/cppcheclipse/p2/updates/
Uncheck "Group items by category"
Select cppcheclipse and click on "Next"
Follow the installation wizard, until installation is complete
Restart Eclipse
Click on Preferences->C/C++->cppcheclipse to setup the path to the cppcheck binary on your computer
where i can find MISRA check
This is not the best place to ask about cppcheclipse configuration. I have not used it. But if cppcehclipse does not allow misra checking yet then you can run cppcheck through "run external command".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Some of the repeated MISRA violations aren't showing in cppcheck.
say for example: "if statement should have a following else statement" this violations is showing for some part of the code only, not all files in my library code.
Could you please help me in fixing this issue
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Some of the repeated MISRA violations aren't showing in cppcheck.
say for example: "if statement should have a following else statement"
this violations is showing for some part of the code only, not all files in
my library code.
Could you please help me in fixing this issue
Hmm, can you try to create a small example where this issue happens?
Without more information i guess it is hard to help.
Which version of Cppcheck are you using that has these issues?
Do you see any "syntax error" messages from Cppcheck for files where the MISRA addon does not report violations? Or are there other "suspicious" messages?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But simply i didn't get that violation result from cppcheck
Do you see any "syntax error" messages from Cppcheck for files where the MISRA addon does not report violations? Or are there other "suspicious" messages?
NO
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Do you mean MISRA results or overall Cppcheck results?
Which version of Cppcheck are you using?
Can you share the (anonymized) command line and project file?
Maybe there is a difference in the platform setting?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi versat,
I got that due to too many #ifdef configurations, when i use --force in CLI
violations are repeated
But in GUI I got those violations only one time.
Do you mean MISRA results or overall Cppcheck results?
MISRA results
Which version of Cppcheck are you using?
Latest cppcheck 1.89
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The equivalent of --forcefrom the CLI is to enable "Force checking all #ifdef configurations" under "Edit" -> "Preferences" in the GUI.
Is that enabled?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok. I can only guess that some other setting (paths, platform, C/C++ standard or so) is still different.
IMHO it is also possible that there really are difference between the results from the CLI and the GUI. Although this should not be i guess it can not be avoided in every case.
But if you have some example so we can reproduce it then it could get fixed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Maybe there is a problem with the file encoding that avoids reading the rule texts.
See this ticket for more details: https://trac.cppcheck.net/ticket/8946
There are some special characters in the PDF and depending on the OS, editor and so on this results in differently encoded rule texts files which may or may not work well.
With the next release of Cppcheck an updated misra addon is delivered that will hopefully address this issue. At least for some widespread encodings.
You can try copying such a character into the file that works and check if it still works. Would be interesting if it has to do with this.
Additionally you can (temporarily) use the misra.py from the repository and see if that works better: https://raw.githubusercontent.com/danmar/cppcheck/master/addons/misra.py
BTW: What Python version do you use?
Last edit: versat 2019-02-06
Ah I see, that makes sense.
I tried to edid the misra.py file with the suggested solutions but it does not help. Maybe I should try Python 2, because I use 3.7.1 at the moment
Edid:
I had a closer look at the used encoding and found some problems there. After adjusting the file with correct tabs and whitespaces it worked!
Thanks for your help :-)
Last edit: Michael Fuchs 2019-02-06
Great!
Thanks for the feedback.
So tabs/whitespaces were a problem? Do you think that this could/should be handled by the script in any better way? If that is something more users could experience i guess it would make sense to handle it.
If you have a dummy file that should work but does not i would appreciate if you can share it (without any rule texts, just some lines that show the problem).
We really should avoid to frustrate the users with such problems if it is possible :)
Hi,
I've created dump files for a library code using
./cppcheck --dump /home/myproject/Baseframework/
This checked for c files recursively and created dump files.
But when i tried this
python misra.py --rule-texts=output.txt /home/myproject/Baseframework/ * .dump
It throws error like
IOError: [Errno 2] Is a directory: /home/myproject/Baseframework/
How can i able to check multiple files in a directory using this script ?
In linux you can use such command:
I want to integrate addons into cppcheck better so it will be easier to run them. Latest cppcheck development snapshot has a
--addon
option. Instead of:You will just execute:
To run misra addon on all source files:
To use that you'll need to have a misra.json file also.. that will just say which addon script you want to run (misra.py) and what additional parameters you want to have (--rule-texts=output.txt).
Hi,
I'm running cppcheck in windows platform.
I've added misra rules in the gui and enabled the addon in my project(cppcheck) .
but the output wasn't showing any misra violations.
I tested the GUI and saw a similar problem. This feels like a severe bug. :-( I have fixed that in git HEAD. If you can test it also I would appreciate..
Hi,
I done this again so far
cloned into your repository
make
make for gui
and ran cppcheck
it has thrown this message
Gtk-Message: Failed to load module "overlay-scrollbar"
and in gui it shown
failed to load cfg "std.cfg"
your cppcheck installation is broken...
and it doesn't showing any misra violations.
is this link has updated cppcheck (for windows 32)
http://cppcheck.sourceforge.net/
Can you please try to fix the
failed to load cfg "std.cfg"
message. This might work:I am not sure if the dump files are generated properly otherwise.
The reason misra does not work is not obvious. I guess it could be some parsing problem of the rule texts. Could you try some other addon first, such as the CERT? If CERT does not work then you have some general problem with addons.
In the cppcheck build folder (see your project file settings) you should see some "...dump-misra-results" files ... do you see those?
That should have the latest release 1.88.
Thanks it worked (in linux platform)(ubuntu 16.04)(not sure about windows platform) :-)
Now i'm getting misra violations
Last edit: B Dharma 2019-07-18
Hi
I'm trying to integrate cppcheck with eclipse.
i've done this so far
Click on Help->Install New Software...
Add the new Update Site https://dl.bintray.com/cppcheclipse/p2/updates/
Uncheck "Group items by category"
Select cppcheclipse and click on "Next"
Follow the installation wizard, until installation is complete
Restart Eclipse
Click on Preferences->C/C++->cppcheclipse to setup the path to the cppcheck binary on your computer
where i can find MISRA check
Last edit: B Dharma 2019-07-19
This is not the best place to ask about cppcheclipse configuration. I have not used it. But if cppcehclipse does not allow misra checking yet then you can run cppcheck through "run external command".
Hi,
Some of the repeated MISRA violations aren't showing in cppcheck.
say for example: "if statement should have a following else statement" this violations is showing for some part of the code only, not all files in my library code.
Could you please help me in fixing this issue
Please notify If there is any update on this.
On Tue, Sep 17, 2019 at 5:12 PM B Dharma bdharma@users.sourceforge.net
wrote:
--
DHARMA.B
Hmm, can you try to create a small example where this issue happens?
Without more information i guess it is hard to help.
Which version of Cppcheck are you using that has these issues?
Do you see any "syntax error" messages from Cppcheck for files where the MISRA addon does not report violations? Or are there other "suspicious" messages?
Hi versat,
Thanks for your reply,
This is my test condition
using the latest cppcheck 1.89, I've created a dump file
And using misra,py along with rule-texts(MISRA text), I tested for misra violation (rule:x "if condition should have terminating else condition")
But simply i didn't get that violation result from cppcheck
Do you mean rule 15.7?
It should only warn when there is at least one
else if
and theelse
is missing.One or more
if
conditions are no problem.Yes
Thanks versat :-)
Hi,
I'm getting different results in CLI (192 violations) and GUI (only 5 violations)
Do you mean MISRA results or overall Cppcheck results?
Which version of Cppcheck are you using?
Can you share the (anonymized) command line and project file?
Maybe there is a difference in the platform setting?
Hi versat,
I got that due to too many #ifdef configurations, when i use --force in CLI
violations are repeated
But in GUI I got those violations only one time.
The equivalent of
--force
from the CLI is to enable "Force checking all #ifdef configurations" under "Edit" -> "Preferences" in the GUI.Is that enabled?
Yes I've enabled all the checks in preferences.
Ok. I can only guess that some other setting (paths, platform, C/C++ standard or so) is still different.
IMHO it is also possible that there really are difference between the results from the CLI and the GUI. Although this should not be i guess it can not be avoided in every case.
But if you have some example so we can reproduce it then it could get fixed.