Menu

Use MISRA rules from the GUI?

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

    basavaraj - 2020-08-31

    Hi ,
    I am facing the same issue,
    as your suggestion i ran the test on misra-test.c
    for cppcheck it says

    basavaraj@basavaraj-VirtualBox:/usr/local/share/Cppcheck/addons$ cppcheck --dump --suppress=uninitvar --suppress=uninitStructMember /home/basavaraj/work/Tools/cppcheck-main/addons/test/misra/misra-test.c
    Checking /home/basavaraj/work/Tools/cppcheck-main/addons/test/misra/misra-test.c ...

    it creates the dump file and when i use the misra.py addon
    i dont see any errors

    i am not sure what i am missing

    i copied the apendix A from misra pdf like below in a text file without any blank spaces
    in 2 ways:
    1)
    Appendix A Summary of guidelines
    Rule 1.1
    Required
    The sentence given in the appendix for this rule
    Rule 1.2
    Advisory
    The sentence given in the appendix for this rule

    2)
    Appendix A Summary of guidelines
    Rule 1.1
    Required The sentence given in the appendix for this rule
    Rule 1.2
    Advisory The sentence given in the appendix for this rule

    both the methods i cant see anything

    checked the below generated table aswell, in both the cases its same
    basavaraj@basavaraj-VirtualBox:/usr/local/share/Cppcheck/addons$ python misra.py -generate-table
    1.1
    1.2
    1.3 X (Cppcheck)
    2.1 X (Cppcheck)
    2.2 X (Cppcheck)
    2.3
    2.4 X (Cppcheck)
    2.5
    2.6 X (Cppcheck)
    2.7 X (Addon)
    3.1 X (Addon)
    3.2 X (Addon)
    4.1 X (Addon)
    4.2 X (Addon)
    5.1 X (Addon)
    5.2 X (Addon)
    5.3 X (Cppcheck)
    5.4 X (Addon)
    .....
    .....
    ....
    till rule 22.6

    i even tried a sample program with violation of Rule 15.7
    still no result

    please help me out where i am doing this wrong
    is there any extra configuration i need to do after installing the cppcheck?

    Thanks in Advance Mate

     

    Last edit: basavaraj 2020-08-31
  • Florian George

    Florian George - 2018-04-26

    Hi Jorge,

    I am not sure if you already fixed your rules.txt, my observation is that rule text that starts lowercase, like "txt rule 1.2" (from your example post) results in that rule being ignored, while rule text that starts uppercase, like "Rule text for 1.2" (from the cppcheck --help example) results in that rule being used.

    This behavior might be a bug.

     
  • Trampas

    Trampas - 2018-04-13

    I wonder if it would be possible to encode the MISRA text into an encrypted binary file and include it with cppcheck? It would not be "easy" for someone to extract and might meet the requirement.

    Another option is to have the application download an ecrypted version at run time. That is the application could send a key to a server and the server could encrypt the text and send a specific copy to the application.

     
    • Daniel Marjamäki

      If it is somehow possible to simplify the usage I would be very interested.

      I doubt that we will be allowed to make it possible for users to freely see the rule texts.

      Just thinking loud: maybe it's possible to have a button in the GUI: Buy PDF.

      Currently we are saying to users that they must write the rule texts file manually. Somehow if they have the PDF it should be possible to also get the rule texts.

      Feel free to make suggestions.

       
  • George

    George - 2018-04-18

    Can I use the Misra rules check from the cppcheck GUI? In the "Addons and tools" tab the MISRA C 2012 option cannot be set. Do I have to put the MISRA addon in a special folder?

     
    • versat

      versat - 2018-04-18

      Yes, sorry there is a bug and the addons are not found.
      It is already fixed so it should work with the next release. This is the ticket for it:
      https://trac.cppcheck.net/ticket/8473
      Until the next version of Cppcheck is released a workaround is to call cppcheckgui.exe with the "--data-dir=<InstallPath>" parameter.
      If you have installed Cppcheck to the default directory something like this should work:

      C:\Program Files\Cppcheck>cppcheckgui.exe --data-dir="C:\Program Files\Cppcheck"
      

      This only sets an according registry entry and when you open Cppcheck the next time the addons should be found and be usable.

       

      Last edit: versat 2018-04-18
      • George

        George - 2018-04-19

        Do I have to put the mysra.py in a specific directory so the cppcheckgui.exe will find it or the misra addon is allready integrated in the GUI?

         
        • versat

          versat - 2018-04-19

          The misra.py should be in the addons directory already and you do not have to (and should not) do anything with it. If you use the workaround as described above the GUI should find the addons.

           
  • Hans Berger

    Hans Berger - 2018-04-25

    Is there a way to show the results from the: misra, y2038 and cert checks
    in the gui?

    I've checked the addon options, i've copyed the *.py files in the \addons dir (as workaround of the bug)

    I've select my misra-rule-text file .

    Cppcheck is working and creates the misra output files
    with the correct rule text in a subdir like:

    myfile.a1.dump.misra-results
    myfile.a1.dump.cert-results
    myfile.a1.dump.y2038-results
    myfile.a1.dump.threadsafe-results
    

    (all file with contents and the correct error description)

    But the cppcheck gui shows nothing from these results files...
    I've checked all speedbuttons (show errors, show warnings, ....)

     

    Last edit: Hans Berger 2018-04-25
  • János Papp

    János Papp - 2018-09-25

    Hello!
    I loaded the hopeful correctly created misra appendix A text file. The misra check results are in the GUI window, but there are no any description of the error. Insted, this description is readable:

    [C:/work/temp/cppcheck-master/gui/aboutdialog.cpp:1]: (style) misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-3.1]</file>

    Do you know what could be the problem?
    I edited the misra text file as exactly written in the manual:
    Appendix A Summary of guidelines
    Rule 1.1
    Rule text
    Rule 1.2
    Rule text
    ...
    But sometimes in the rule text there is an enter. Could this be a problem?

     
    • versat

      versat - 2018-09-26

      Your misra text file looks good.
      I verified with Cppcheck V1.84 that a new line in the rule text is no problem.
      And it does not matter whether Unix or Windows new lines are used.
      So i really do not know what could be the problem.
      Maybe somehow the file is not found? Did you specify it via the GUI file selection dialog?

       
  • Daniel Marjamäki

    you could also try to run the misra checks on the command line and see if you can reproduce the problem there also.

    cppcheck --dump somefile.c
    python misra.py --rule-texts=<your file> somefile.c.dump
    

    If this only happens in the GUI I would assume that it's a setting problem

     
    • János Papp

      János Papp - 2018-09-27

      Hey!

      I can recognize different behaviors.

      • When I'm running from cmd line for your misra_test.c test file I get the arrached cmd_line_results.txt
      • When I'm running from gui for the same file I get the attached misra_test_c_report.xml.
      • If I'm opening a visual studio solution (sln file) sometimes I get correct description of rules, sometims I get onle the rule number (Rule 21.1 for eg.)

      Is there a possibility to run misracheck from the visual studio plugin?

      And yes, I specified the misra text file in the gui and it is enabled.

       

      Last edit: János Papp 2018-09-27
  • Daniel Marjamäki

    does it help to provide the absolute path for the misra rule texts?

    I am thinking that it would be nice to know what exact command the GUI uses . It must somehow be different to the command you used on the command line. I believe you can see it somehow but not sure how..

     
    • János Papp

      János Papp - 2018-10-01

      I tried with cmd line version absolute and relative path. Both worked well.
      But in the gui I cannot add realtive path... I'm just browsing for it... Or this is not what you have meant?
      Another question: Can I use misra check in the visual studio plugin?

       
    • Bassam Abdul-Baki

      I figured out the problem. If your rules text begin with a paranthesis or a non-alphanumeric character, it fails to load it. Mine were written as "(Ad|Ma|Re): Rule text." Once I removed the open paranthesis, it worked fine. I actually changed them to "Ad|Ma|Re - Rule text.".

      Looking at your misra.py code, I see you do read the category pattern as " (Advisory|Required|Mandatory)". The documentation does not mention this at all. Also, your Misra 2012 is for the original standard and not for Ammendment 1.

       

      Last edit: Bassam Abdul-Baki 2018-10-27
  • Bassam Abdul-Baki

    My python skills are non-existant, however looking at the function loadRuleTexts in misra.py (line 1863), it seems that the Choice_pattern is unused. It would be nice if it were. However, the elif checks on lines 1895 and 1901 are what confuse me since I don't understand why they are split up. In addition, I do not understand why the first string pattern may start with # (followed by uppercase) while the latter (lowercase) may not.

     
  • Bassam Abdul-Baki

    After playing around with the misra.py code, I've come to the conclusion that the MISRA compliance choices (A.K.A., the choice patterns: Advisory|Required|Mandatory) cannot be placed in the Severity column since those are a hardcoded list in the CPPCheck code. I was able to modify the Python code to read them, but they had to be placed in a separate line after each rule number. It was a lot easier to just add them before the rule text, but that defeated the purpose of attempting to have them appear in the Severity column. Personally, I'd rather see them added after the rule number, as opposed to another line for each rule, and placed in Severity. They could also be added to the errorID column, but that seemed wrong for some reason. Time to undo the changes and wait for CPPCheck's decision.

     
  • LTLaney

    LTLaney - 2019-01-24

    Hello!

    I've installed the cppcheck 1.86 via windows installer, than copied the addon folder to the cppcheck directory. Since than i could enabled the MISRA C 2012 addon and import misra rules in .txt file inside the GUI. When i run the analysis GUI finds the MISRA violations, but it says. "misra violation (use --rule-txt=<file> to get proper output)". To get which rule number i'm violating i have to go to main.dump-misra-results, and than go to the MISRA PDF to get the rule number meaning. What i'm doing wrong, since my misra_rule.txt(rules descripions) has no impact in analysis...</file>

    Thanks

     

    Last edit: LTLaney 2019-01-24
    • Daniel Marjamäki

      Click on the menu item: Edit -> Preferences

      In the Preferences window, goto the tab called "Addons".

      Make sure that the text box "Misra rule texts file" say the path to your misra rule texts file.

       
  • LTLaney

    LTLaney - 2019-01-24

    Thank you for your reply.

    I checked and the path was ok. But after that i've noticed were i was sloppy.
    My text file started like that:

    Rule 1.1
    Rule text ...
    Rule 1.2
    Rule text ...

    Since i've added first line like below it started working:

    Appendix A Summary of guidelines
    Rule 1.1
    Rule text ...
    Rule 1.2
    Rule text ...

    Thank you for MISRA checker.
    I don't find donate section on cppcheck website. I would donate something symbolic =)

     
  • Daniel Marjamäki

    I don't find donate section on cppcheck website. I would donate something symbolic =)

    Thanks!

    I think that donating money to the cppcheck team is not that useful. We have a little amount of money and I do not know what to do with it. I would like to distribute it in some fair way to the team but there are 100's of team members; I do not know how to do that.

    I would prefer one of these options:
    1. donate to osuosl. They provide a server for us that is crucial for development.
    2. if you want to add a bounty for some ticket let me know.

     

    Last edit: Daniel Marjamäki 2019-01-27
  • Michael Fuchs

    Michael Fuchs - 2019-02-06

    Hello!

    I have installed Ccpcheck 1.86 and it works well generally.
    In order to use the Misra Addon I also bought the Misra PDF and converted it to a text file as described in the Manual. I get the misra violations, but without any information ("misra violation(use --rule-texts=<file> to get proper output)").</file>

    I tried different formatted textfiles, but nothing changed.
    The path in the settings is correct.
    Could you give me more detailed information about how to format the textfile?
    e.g.:
    Do I have to dump the Advisory, Mandatory, Required words?
    The Chapter starts with Dirs instead of Rules, do I have to write them to the file too?

    I tried one textfile like this:
    Appendix A Summary of guidelines
    Rule 1.1
    Rule text ...
    Rule 1.2
    Rule text ...

    And one like this:
    Appendix A Summary of guidelines
    Rule 1.1
    Required/Mandatory/Advisory
    Rule text ...
    Rule 1.2
    Required/Mandatory/Advisory
    Rule text ...

    Thank you

     

    Last edit: Michael Fuchs 2019-02-06
    • versat

      versat - 2019-02-06

      A rule texts file with a format like this should work:

      Appendix A Summary of guidelines
      Rule 1.1
      Text of rule 1.1
      Rule 1.2
      Text of rule 1.2
      

      Can you play around with the path that is specified for the rule texts file?
      Trying absolute or relative paths and see what works?

       
      • Michael Fuchs

        Michael Fuchs - 2019-02-06

        Thank you for your answer.

        I already tried absolute and relative paths without success. I even get the same result if no path is set at all.

        Edid:
        I tried a new textfile with only one rule in it and it works. So the problem has to be somewhere in the old files.

         

        Last edit: Michael Fuchs 2019-02-06
<< < 1 2 3 4 .. 6 > >> (Page 2 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.