Up User guide

3.4 Configuring checks

Code Checker for MATLAB has standard reports and checks that are configurable. This way, the code checker can be adapted to fit the company’s or the team’s coding standards. A configuration file allows to define:
The reports contain the configurations defined for the check and link it to an internal guideline, see Figure 3.10↓. It also includes a link to directly open the configuration of a specific check in the Configuration Editor. If you have specified a guideline link, this will be accessible by clicking the guideline ID in the report. If the link refers to a webpage, the guideline link must start with https:// or http:// (before www). If your guideline link contains a local drive address (i.e. C:\), links to specific pages in a PDF will simply open the file to the first page.
figure images/link_with_guideline_info.png
Figure 3.10 The link information with a guideline as shown in a report.
In order to provide insight in the settings of a check, information on its parameters is given in the report generated by Code Checker for MATLAB. For every check that is enabled and has at least one parameter, the name, description, type, value and allowed values are shown. This information is obtained from the active configuration file. A link is also included that can be used to open the Configuration Editor to a specific parameter. An example of the information on a parameter for the check on variable casing as given in the report is shown in Figure 3.11↓.
figure images/parameter_info.png
Figure 3.11 Information about the AllowNumbers parameter of checkVariableCasing.

3.4.1 Edit the configuration file

Chapter 4↓ describes the Configuration Editor for the Code Checker for MATLAB. It is used to open the configuration file of your choice interactively. The Configuration Editor can be opened by using the Open button on the Configuration tab in the Code Checker for MATLAB GUI. The selected configuration file will be activated and opened. The Configuration Editor can also be opened from the Meta data section in a Code Checker for MATLAB report using the Open button next to the configuration file path. To start editing the configuration of a specific check or parameter, use the links in the check result tables of a Code Checker for MATLAB report. You will not be able to save any configuration files in the folder for predefined configurations shipped with Code Checker for MATLAB (see Chapter 5↓).
You could also edit the XML file directly in the text editor of your choice. However, this is not recommended because it is unintuitive and error-prone. The Configuration Editor makes sure that the edits you make and save, make the configuration file pass validation.

3.4.2 Update the configuration file

If a new version of Code Checker for MATLAB is released, new checks and check parameters may be added. Your existing configuration file can be updated so that it will include these missing parts with default values. After updating, the newly added check configurations can be edited so that they apply the settings reflecting your coding standards and guidelines. Configuration files can be updated using one of two syntaxes:
% Update the currently active configuration file.
% Update the specified configuration file.
As described in Chapter 4↓, this option is also available in the Configuration Editor by clicking Add missing elements. If you have run Code Checker for MATLAB and a report was generated, it will include a section on missing check or parameter configuration. It also includes a link to directly update the configuration file. After using any of these last two options, a dialog is shown that tells you what checks and parameters were added. If you call monkeyproof.cc4m.updateConfigurationFile from the MATLAB command window, the list of added checks and parameters is given as an output to the function call.
Comments in the configuration file get lost during this process. It is therefore advisable to -if applicable- adjust the description of a check or parameter instead of placing the additional information in comments the xml file.
Empty lines in the xml file are also lost during this process.
It is not allowed to update a predefined configuration.

3.4.3 Multiple configurations per check

To allow for a better mapping of your coding standards onto your Code Checker for MATLAB configurations file, one check can be configured multiple times. The Code Checker distinguishes between different configurations based on the guideline identifier. This is useful for example when there are multiple guidelines on what built-in functions to avoid using, each with their own rationale, ID and list of function names. The Configuration Editor fully supports multiple configurations per check, see Section 4.5↓. Results for a check that is configured more than once do have an individual checks result table in the report. Based on the guideline identifier you can distinguish between the different results.
If the same check is configured multiple times, the additional configurations of the check are ignored when checking your code if one of the following is true:
You can exempt specific configurations of a check or all configurations of the same check. This is described in Section 3.9↓.
Up User guide