Menu

Different results for misra addon depending on how it is invoked

2022-02-08
2022-02-10
  • José Martins

    José Martins - 2022-02-08

    I first noticed that the misra addon was not detecting a violation of rule 2.5 on such a simple file as:

    #define THIS_MACRO_IS_NOT_USED
    
    static int f(void) {
        return;
    }
    

    Then I noticed that depending how I invoked the addon the "violation" was detected or not. If I invoke it simply as cppcheck --addon=misra r2_5.c, the violation warning is spit out. If I use instead cppcheck --addon=misra.py r2_5.c, no warning is shown. Finally, if I use a separate JSON file like so cppcheck --addon=misra.json r2_5.c with the following misra.json file:

    {
        "script": "misra.py"
    }
    

    also, no warning. Here is the output of the three attempts:

    [23:20] misratests | cppcheck --addon=misra r2_5.c   
    Checking r2_5.c ...
    r2_5.c:1:0: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-2.5]
    #define THIS_MACRO_IS_NOT_USED
    ^
    [23:20] misratests | cppcheck --addon=misra.py r2_5.c
    Checking r2_5.c ...
    [23:21] misratests | cppcheck --addon=misra.json r2_5.c
    Checking r2_5.c ...
    [23:23] misratests |  
    

    Is this a bug or a "feature"? If there is no problem, is it something I'm missing on how to correctly invoke the addon? I'd like to use the json variant so that I can pass the --rule-texts option.

    Finally, note that I compiled cppcheck by cloning it from github, checking out the 2.7 tag, and running the following commands:

    #make -j$(nproc) FILESDIR=/usr/share/cppcheck
    #sudo make install FILESDIR=/usr/share/cppcheck
    

    Cheers

     
  • José Martins

    José Martins - 2022-02-10

    I've submitted a PR which I believe fixes the issue: https://github.com/danmar/cppcheck/pull/3819

     
  • José Martins

    José Martins - 2022-02-10
     

    Last edit: José Martins 2022-02-10

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.