3.4 MISRA Check Tab

To open the MISRA Check tab, select Tools>Options>Embedded>MISRA Check.

The MISRA Check tab below supports checking your application code against your choice of enabled standards. All MISRA C:2012 rules are listed in the table. Grayed out rules are to be checked manually. Applied rules can be enabled and disabled.

Figure 3-1. MISRA Check Tab

Run each time project is rebuilt

Check to execute static code analysis as part of the build.

Allow rule suppression with code comments

Suppress rules that have been commented in the code.

Generate report files

Check to generate MISRA Check reports in HTML or CSV format. Reports are timestamped. HTML or CSV reports are written to <project folder>\report. Also a “report” folder is added to the project tree from which the files may be viewed.

The HTML report lists:

  • When the check was executed
  • Rule violations – issues found
  • What was checked
  • And which rules was applied

The CVS report lists:

  • Rule violations – issues found

Use custom Cppcheck path

Provide a link to a custom Cppcheck to override the MPLAB X IDE bundled Cppcheck. Use this to extend/modify/update the applied rule checking.

Use custom Cppcheck platform file

Provide a link to a custom Cppcheck platform file. You should use a platform configuration that matches your target environment.

Additional Cppcheck arguments

Note: This features is available in MPLAB X IDE v6.05 and greater.
  • In GUI: open MISRA options and fill in Additional Cppcheck arguments. Settings will be used next time MISRA analysis is run.
  • On CLI: use --cppcheckArgs as following:
    misracli.bat --xclm=[XCLM_PATH_HERE] --cppcheckArgs "-v" .

Excluding files using --excludePattern (CLI only):

To exclude source files when running the MISRA analysis use the --excludePattern. This will ignore files based on global pattern matcher filter

  • Following example will run MISRA analysis on all files under current directory unless their name include "test":
    misracli.bat --xclm=[XCLM_PATH_HERE] --excludePattern "**/*test*" .
  • Following example will run MISRA analysis on all files under current directory unless they are in a subfolder
    misracli.bat --xclm=[XCLM_PATH_HERE] --excludePattern "subfolder/**" .

Specifying custom cppcheck arguments:

The cppcheck arguments are documented here: https://linux.die.net/man/1/cppcheck

As an example, add the -v option which just increases the verbosity and it will output Defines, Undefines, Includes and Platform each time it starts to process a new file.