Menu

Use MISRA rules from the GUI?

2017-12-07
2021-06-13
<< < 1 2 3 4 5 6 > >> (Page 3 of 6)
  • versat

    versat - 2019-02-06

    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
    • Michael Fuchs

      Michael Fuchs - 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
      • versat

        versat - 2019-02-07

        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 :)

         
  • B Dharma

    B Dharma - 2019-06-11

    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 ?

     
  • Daniel Marjamäki

    In linux you can use such command:

    find /home/myproject/Baseframework/ -name \*.dump | xargs python misra.py --rule-texts=output.txt
    

    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:

    ./cppcheck --dump somefile.c
    python misra.py --rule-texts=output.txt somefile.c.dump
    

    You will just execute:

    ./cppcheck --addon=misra.json somefile.c
    

    To run misra addon on all source files:

    ./cppcheck --addon=misra.json /home/myproject/Baseframework/
    

    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).

     
  • B Dharma

    B Dharma - 2019-07-17

    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.

     
  • Daniel Marjamäki

    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..

     
  • B Dharma

    B Dharma - 2019-07-18

    Hi,
    I done this again so far

    cloned into your repository

    git clone https://github.com/danmar/cppcheck.git
    

    make

    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.

     
  • B Dharma

    B Dharma - 2019-07-18

    is this link has updated cppcheck (for windows 32)
    http://cppcheck.sourceforge.net/

     
  • Daniel Marjamäki

    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.

     
  • B Dharma

    B Dharma - 2019-07-18

    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
  • B Dharma

    B Dharma - 2019-07-19

    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
  • Daniel Marjamäki

    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".

     
  • B Dharma

    B Dharma - 2019-09-17

    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

     
    • B Dharma

      B Dharma - 2019-09-19

      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:

      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


      Use MISRA rules from the GUI?
      https://sourceforge.net/p/cppcheck/discussion/general/thread/ccbe9e89/?limit=25&page=2#f836


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cppcheck/discussion/general/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      DHARMA.B

       
    • versat

      versat - 2019-09-25

      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?

       
      • B Dharma

        B Dharma - 2019-09-25

        Hi versat,
        Thanks for your reply,
        This is my test condition

        #include<stdio.h>
        
        int main()
        {
            int a;
            (void)printf("\nEnter any number\n");
            (void)scanf("%d",&a);
            if(a == 1)
            {
                //
            }
            if(a == 2)
            {
                //
            }
            if(a == 3)
            {
                //
            }
            return 0;
        }
        

        using the latest cppcheck 1.89, I've created a dump file

         ./cppcheck --dump /home/user/test_cppcheck_misra.c 
        Checking /home/user/test_cppcheck_misra.c ...
        

        And using misra,py along with rule-texts(MISRA text), I tested for misra violation (rule:x "if condition should have terminating else condition")

        python addons/misra.py --rule-texts=/home/user/CppChecks/misra2012_rules.txt /home/user/test_cppcheck_misra.c.dump 
        Checking /home/user/test_cppcheck_misra.c.dump...
        

        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

         
        • versat

          versat - 2019-09-25

          Do you mean rule 15.7?
          It should only warn when there is at least one else if and the else is missing.
          One or more if conditions are no problem.

           
          • B Dharma

            B Dharma - 2019-09-25

            Yes
            Thanks versat :-)

             
  • B Dharma

    B Dharma - 2019-09-24

    Hi,
    I'm getting different results in CLI (192 violations) and GUI (only 5 violations)

     
    • versat

      versat - 2019-09-25

      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?

       
      • B Dharma

        B Dharma - 2019-09-25

        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

         
        • versat

          versat - 2019-09-25

          The equivalent of --forcefrom the CLI is to enable "Force checking all #ifdef configurations" under "Edit" -> "Preferences" in the GUI.
          Is that enabled?

           
          • B Dharma

            B Dharma - 2019-09-25

            Yes I've enabled all the checks in preferences.

             
            • versat

              versat - 2019-09-25

              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.

               
<< < 1 2 3 4 5 6 > >> (Page 3 of 6)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.