Menu

Suppressing CERT-C rules

2021-11-12
2021-11-17
  • Richard Slindee

    Richard Slindee - 2021-11-12

    Hello,

    I'm having some troubles trying to suppress specific CERT-C rules using the cert.py addon in cppcheck 2.6.

    Right now I'm able to successfully run cppcheck with both misra.py and cert.py. I am able to configure the MISRA addon to ignore multiple rules. With that said, I am having difficulties disabling CERT-C rules in a similar fashion.

    I'm running the following line:

    cppcheck --language=c --file-filter=*.c --addon=misra.json --addon=cert.json my_code_directory
    

    I'm able to successfully "ignore" all instances of specific MISRA warnings with the following misra.json:

    {
      "script": "misra.py",
      "args": [
        "--rule-texts=misra-c-2012.txt",
        "--suppress-rules 1.1,2.5,5.1"
      ]
    }
    

    With that said, I cannot seem to do the same with my CERT-C equivalent cert.json:

    {
      "script": "cert.py",
      "args": [
        "--suppress-rules EXP05-C"
      ]
    }
    

    Where I get the following error:

    cert.py: error: unrecognized arguments: --suppress-rules
    

    I tried digging through the documentation pdf, --help, and cppcheck forums, but cannot seem to find a solution. Thus, my questions are:

    1. Is it possible to suppress/ignore all checks of specific CERT-C rules when running cppcheck?
    2. If so, would it be possible to get an example of a working .json configuration which suppresses one or more CERT-C rules?

    Thank you!

    -Richard

     
  • Daniel Marjamäki

    as you saw, the --suppress-rules option is only available in misra.

    a solution that works for all addons, including misra, is to use --suppress or --suppressions-list on the cppcheck command line.

    cppcheck --language=c --file-filter=*.c --addon=misra.json --addon=cert.json my_code_directory --suppress=cert-EXP05
    
     

    Last edit: Daniel Marjamäki 2021-11-12
    • Richard Slindee

      Richard Slindee - 2021-11-17

      Thank you very much for the quick reply! I believe my confusion was surrounding what suppression arguments should be specified in the .json file versus the CLI call. Your example works wonderfully.

       

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.