Configuration Editor

The Configuration Editor lets you interactively configure the CC4M's checks such that they reflect your coding rules. You can also adjust one of the predefined configurations to your liking.

Opening the Configuration Editor

The Configuration Editor can be opened in multiple ways:

  • From the GUI using the Open button on the Configuration tab.

  • By calling monkeyproof.cc4m.openConfigurationFile(configFile); where configFile is an optional input: the configuration file to edit and activate. If left out, the currently active configuration file is opened.

  • By clicking one of the links in a CC4M report:

    • In the Metadata section, the Open button next to the configuration file path.

    • At a check's information, the Open check configuration link. If the check is not yet configured, you will be prompted to add it to your configuration file so that you can edit it.

    • In the parameter information table of a check, the Open link. If the parameter is not yet configured, you will be prompted to add it to your configuration file so that it can be edited.

As the Configuration Editor opens, the active configuration file is validated against a Schema file. If it succeeds, you will see an interface as shown in the figure below. If the Schema validation fails, you will see a message describing why it fails. The configuration file can not be loaded and you will have to either open another configuration file, or edit the current configuration file in a text editor and try to open it in the Configuration Editor again.

After successfully opening your file, you will see the following things:

  • The full path of the currently opened configuration file.

  • The editable description of the configuration file.

  • A list of CC4M checks and reports with for each check/report the following information:

    • Rule identifier

    • Reference number

    • Description

    • Name

    • Whether or not they are enabled.

If you already have an opened Configuration Editor in the current MATLAB session, the actions listed above will simply bring the window forward.

Note: In MATLAB R2017b, minimized Configuration Editor windows will remain minimized when one of these actions are performed. Resizing the application may not work properly for MATLAB R2017b. Maximizing the window makes sure all controls are at least accessible.

The Configuration Editor after it has just opened

The Configuration Editor after it has just opened

Editing the configuration of a check

You can enable or disable checks by checking or unchecking the checkbox on their respective rows. You can also enable or disable all checks at once using the Enable all/none button right above the Enabled column. Clicking a check's name or description will display its configurations on the right, like shown in the figure below. You can now see and/or edit the following:

  • The buttons Clone and Remove, will be discussed in Clone and remove check configurations.

  • The check's description. This will also be displayed in CC4M reports.

  • Whether or not to enable the check.

  • The priority of the check. Options are Recommended, Strongly recommended, and Mandatory.

  • The severity level of the check, can be in the range from 1 to 10. The most important ones are of severity level 1 and next levels are reserved for more pedantic issues. The severity levels are derived from the following webpage.

    • 1 - Certainly a programming error

    • 2 - Very likely a programming error

    • 3 - Programming pitfall/undesired programming construct/accident waiting to happen

    • 4 - Design issue with high impact on reliability or maintainability'

    • 5 - Design issue with low impact on reliability or maintainability

    • 6 - Portability or performance issue or high impact other issue

    • 7 - Comment related issue or medium impact other issue

    • 8 - Naming convention or low impact other issue

    • 9 - Style related issue

    • 10 - Controversial issue or issue with a relatively high false positive rate

  • Categories of the check. Use this to tie the checks to groups of coding standards. The value shall be a semicolon-separated list of categories.

  • A rule link for linking the check to a rule. Weblinks should start with https:// or http://.

  • The Go to button that goes to where the rule link is pointing, if the rule link field is empty, this button is disabled.

  • The rule identifier.

  • If the check has configurable parameters, their names and descriptions are shown. By default, the first parameter in the table is selected and its details are shown below the table.

The Configuration Editor after a check is selected

The Configuration Editor after a check is selected

Selecting a parameter will show the parameter description and its value(s). By default, the first parameter of a check is selected (if there are any) when the check is selected in the checks table. Depending on the data type of the parameter, different components are used to edit the parameter value:

  • For boolean parameters, a switch to choose between True and False is shown. This is also shown in the figure below.

  • For parameters of type double, a numeric text field is shown that applies the minimum and maximum values of the parameter.

  • If parameters of type string have any allowed values, a dropdown menu is shown that lets you select one value.

  • Parameters of type string that have no allowed values, a textbox is shown that lets you type the parameter value.

  • For parameters of type list, a dropdown menu is shown if there are allowed values. Depending on the parameter, one or more parameter values can be selected.

  • If there are no allowed values, parameter values of type list can be typed in a text box using one value per line.

The Configuration Editor after a check and parameter have been selected

The Configuration Editor after a check and parameter have been selected

Selecting a different check or parameter after editing one will store any edited values so these will not be lost. Clicking Save or Save as... lets you save the configuration file such that the updated configuration file can be used for checking your code. Please note that the configuration file is generated using the global description and the checks and parameters as they are in the Configuration Editor. This means that if your configuration file contained comments or empty lines before, they will no longer be there. If you are editing a predefined configurations file shipped with CC4M (see section Predefined Configurations), the Save button will be disabled because it is not allowed to save configuration files in the folder for predefined configurations. You will have to save the file in a different location.

Note: Creating, opening or saving a configuration, selects it as the active configuration in CC4M.

Find checks efficiently

With the large amount of checks CC4M provides, it may be difficult to find what you are looking for. For this reason, you can use the search bar above the table of check configurations to filter the rows in the table. When searching, keep the following in mind:

  • Separate multiple search terms using spaces.

  • A check configuration is found if at least one of the search terms is found in (part of):

    • The rule identifier (column 1 in the table)

    • The rule description (column 3 in the table)

    • The check's name (column 4 in the table)

    • The categories of the check's configuration

    • The parameter descriptions of the check configuration. These are not editable.

  • You can filter the checks by priority by entering Mandatory, Strongly recommended or Recommended.

  • Show only the enabled/disabled checks by searching for Enabled or Disabled.

  • The search is case-insensitive.

  • Show all check configurations by clearing the search bar.

Adding missing checks and parameters

If you update the CC4M release you are using, checks and parameters may have been added to the tool that are not configured in your configuration file yet. If you load such a configuration file in the Configuration Editor, you will see the Add missing elements button above the configuration's description. The checks and parameters do not show up in the table of checks or the table of parameters (on the right). Clicking Add missing elements will add the missing checks and parameters to the bottom of the configuration using default values. A dialog will show which checks and parameters were added, such that you can easily configure them to have them reflect your coding standards.

Clone and remove check configurations

As discussed before in section Multiple configurations per check, it is possible to have more than one configuration per check, provided that the ruleID is different for all configurations of the check. If a check that has configurable parameters is selected in the Configuration Editor, the Clone button will be enabled. Clicking Clone will clone the selected check and you can start editing this new configuration of the check. In figure The Configuration Editor after a check and parameter have been selected a check with configurable parameters is selected and therefore the Clone button is enabled. In case a check is configured more than once, it is possible to remove additional configurations. Clicking Remove will remove the selected check configuration. The Remove button is only present in case a check is selected that is configured more than once.

Reference configurations

As discussed before in section Referencing configurations it is possible to reference other configurations from within the Configuration Editor. This can be done from the second tab, the Referencing tab, see the figure below. One can reference a custom configuration file by browsing to the file. The custom configuration file will be added after the Confirm button has been clicked. One can reference a predefined configuration by selecting via the dropdown menu. The predefined configuration will be added after the Confirm button has been clicked.

The Configuration Editor when predefined configuration MonkeyProof MATLAB Coding Standard++ has been selected.

The Configuration Editor when predefined configuration *MonkeyProof MATLAB Coding Standard++* has been selected.

If a custom configuration file or a predefined configuration has been successfully incluced a confirmation dialog will be shown. The dialog contains information on how many checks have been included. Only enabled checks will be included. Identical check configurations from a referenced configuration (file) will not be included since they do not lead to unique results. After including a referenced configuration, a tree of the referenced configurations will be shown in the Configuration Editor, see the figure below. After including predefined configuration MonkeyProof MATLAB Coding Standard++, a number of check configurations have been added. To distinguish between the check configurations that originate from the active configuration file and the ones that are referenced, all check configurations will have a Reference number as can be seen in the second column (Ref) of the list of CC4M checks and reports. For check configurations that originate from the active configuration file Reference number = 1 , for check configurations referenced from the predefined configuration MonkeyProof MATLAB Coding Standard++, Reference number equals 2. To remove all check configurations from a referenced configuration, click the Remove button.

The Configuration Editor after predefined configuration MonkeyProof MATLAB Coding Standard++ has been included.

The Configuration Editor after predefined configuration *MonkeyProof MATLAB Coding Standard++* has been included.

After selecting a referenced check in the the list of CC4M checks and reports the following icon image illustrates that it's about a reference. If one wants to delete a referenced check configuration, after selecting the specific referenced check, click the Delete button, similar to the Remove button as discussed in section Clone and remove check configurations. If one wants to clone a referenced check configuration, after selecting the specific referenced check, click the Clone button. After cloning the clone will be part of the active configuration file and will no longer be linked to the referenced configuration file.