Configuring code review rules

Code Review for C

The code review tool uses a set of predefined rules. You can select the default rule configuration file for the code review tool. MISRA 2004 and MISRA 2012 from HCL OneTest Embedded Studio V8.2.0 are the default installed rule configuration files. You can either disable or set the severity level to Warning or Error.

By default all rules are enabled and produce either an error or a warning in the code review report. You can save multiple customized rule policies.

The default rule policy files are located in the <installation directory> /plugins/Common/lib/confrule.xml file for MISRA 2004 and in <installation directory> /plugins/Common/lib/confrule_2012.xml for MISRA 2012.

Note All new projects use the default rule configuration file that you have selected in the configuration settings. Do not modify the default rule configuration files. The only change that can be done in the default rule configuration files is to change or disable the severity level of the rule from the settings.

To select the configuration file and disable or set the severity level of code review rules:

  1. Select a node in the Project Explorer view and click the Settings button.
  2. In the Configuration Settings list, select Code Review.

    In Default configuration, select the MISRA rules to apply to your project: MISRA 2004 or MISRA 2012.

  3. To modify the default set of rules, in Rule configuration, click ...and select the rule file that you want to configure.
  4. In Rule configuration click Edit . This opens the Rule Configuration window where rules are grouped into categories.
    Note: You can filter the rules by labels from the Find field. Search is not case sensitive. When a rule is selected, its description is displayed on the right panel with the parameter description and value if they are defined in the selected rule.
    Misra rules configuration settings
  5. Select the severity level:
    • Disabled: The selected rule is ignored. The list of disabled rules is displayed at the end of the report.

    • Warning: When any non-compliance instance is found, a warning is displayed in the code review report.

    • Error: When any non-compliance instance is found, an error is displayed in the code review report.

    Note: Multiple user-custom rules (from Rule U99.1 to Rule U99.10) can be defined for MISRA 2004 and MISRA 2012 with their own severity level.
  6. Select Show only the first occurrence to only show the first occurrence of a non-compliance in a file.
  7. Select Save and Close to save the current configuration or Save As to create a new rule configuration file.

If your application is multi-threaded, you can provide the list of entry points to avoid that the rules about 'non-used functions' are raised.

To configure the Multi_thread option, follow these steps:

  1. Click Configuration Properties > Runtime Analysis > Multi-threads.
  2. In the right pane, click ... in the value field of the Entry points option to open the editor.
  3. In the editor, enter the list of entry points for each thread and click OK

    The Entry point option applies to rule E16.50 (MISRA_2004) and M2.2.2 (MISRA 2012).

Related Topics

Code review overview | Code review settings | Code review rules | Understanding code review reports