6.1 Run from the command window
Calling monkeyproof.cc4m.start without input arguments opens the graphical user interface that lets you choose what files to check and how. Almost all of these options are also available from the MATLAB command window. In the different options and syntaxes described in this chapter, character vectors and cell arrays thereof are used. The same options can also be used using strings and string arrays.
6.1.1 Select files for checking
The file(s) or folder to run the Code Checker for MATLAB on can be set using the following syntaxes:
>> monkeyproof.cc4m.start(’file’, location);
Runs the checks on the file(s)/folder location (absolute path).
-
If location is a MATLAB file (.m or .mlx), only that specific file is checked.
-
If location is a cell array of MATLAB file names or a semicolon-separated list of MATLAB file names, these are all checked.
-
If location is a folder, all MATLAB files in that folder (non-recursively) are checked.
-
If location is a file with extension .txt, the file is read and the list of MATLAB files within it is checked. All files listed in the txt-file must be on a separate line.
-
If location is a file with extension .prj, the files in the given MATLAB project are checked. The project will be loaded (closing the open project if any) before checking the code.
Instead of providing the file/folder/project to check directly in the input, the following options can be used:
>> monkeyproof.cc4m.start(option);
Where option can be one of the following:
-
’-editor’ runs the checks on the file that is currently open in the MATLAB editor (if there is one open and it is an m-file). Even though live editor files can be checked using Code Checker for MATLAB, this option does not support it and you will have to enter the live editor file using another option.
-
’-pwd’ runs the checks on the current working directory (as would be returned by MATLAB when calling function pwd).
-
’-browse’ lets you browse for a folder whose files to check. Browsing for a file to check is not supported by this option.
-
’-currentProject’ runs the checks on the files of the currently open MATLAB project.
6.1.2 Additional options
The runPriorities parameter can be used to run only the checks with the given priorities. The syntax for doing this is as follows:
>> monkeyproof.cc4m.start(..., ’runPriorities’, {’Recommended’, ’Strongly recommended’});
This would run all checks (that are not disabled by your configuration file) with priority Strongly recommended and Recommended. The supported priorities are: Mandatory, Strongly recommended, and Recommended. If the parameter is omitted from the inputs, checks with all priorities will run. This option applies check filtering on top of what is configured in your configuration file.
The runSeverities parameter can be used to run only the checks with a severity level below or equal to the maximum level set. The syntax for doing this is as follows:
>> monkeyproof.cc4m.start(..., ’runSeverities’, 5);
This would run all checks (that are not disabled by your configuration file) with a severity level between 1 and 5. The supported severities are in the range of 1 through 10. The most important ones are of severity level 1 and next levels are reserved for more pedantic issues. If the parameter is omitted from the inputs, checks with all severity levels will run. This option applies check filtering on top of what is configured in your configuration file.
Additional options can be provided as input arguments to further customize the run. The syntax is as follows:
>> monkeyproof.cc4m.start(..., option1, ..., optionN);
where option1 through optionN can be the following:
Additionally the file location of the created report can be returned:
>> fileLocation = monkeyproof.cc4m.start(...);
Setting the MATLAB path
In order to make sure that the right folders are on the MATLAB path at the time of checking, an additional input parameter can be provided. The syntax is as follows:
>> monkeyproof.cc4m.start(’matlabPath’, ’C:\Files\myFolder;C:\AnotherFolder’);
>> monkeyproof.cc4m.start(’matlabPath’, ’C:\Files\MyDocuments\MyPath.txt’);
The MATLAB path to set can be a semicolon-separated character array of the different parts of the path. Alternatively, the path can be provided in a txt-file. This text file can have the different parts of the path on separate lines, or they can be separated by semicolons.
The path used during the Code Checker for MATLAB run is set as follows:
-
Keep all folders that contain MATLAB-installed functionality on the path.
-
Keep all Code Checker for MATLAB code on the path.
-
Add the parts of the path specified in the input by the user to the path.
The approach listed above allows you to specify only the paths of the code that you want to check and of the local code it depends on.
Some additional remarks regarding this feature:
-
It is not a problem if the same folders are added to the path multiple times.
-
After the report has been generated, the original MATLAB path is restored.
-
If this option is used, the code selected for checking is not added to the MATLAB path if the path you specify does not say so.
Adding an additional comment to the report
It’s optional for the user to add an additional comment to the report, for example the URL of the pull request that triggered the Code Checker for MATLAB run. The syntax is as follows:
>> monkeyproof.cc4m.start(..., ’comment’, ’I-Triggered-The-CodeCheckerForMATLAB-Run’);