Up User guide

3.6 Reports

There are a number of standard reports that can be run by Code Checker for MATLAB. These are explained in the following sections. When selecting the option Include reports in the GUI, the full results of all standard reports are shown. If this option is not selected, only the violations and errors encountered by the standard reports are reported. For every standard report, an exemption tag is given. For more information about this, see Section 3.9↓.

3.6.1 Meta data and summary

Under meta data, the following things are listed:
The summary shows which checks have failed for at least one of the checked files. In case the Include passed checks option, see Section 3.3.3↑, is enabled the summary contains information on all checks ran, which might include passed checks as well. The summary provides the following things:
If a file contains a parse error or invalid characters, Code Checker for MATLAB cannot check it. The summary will include a list of all the checked files that contain a parse error or invalid character. The files can be clicked which will open the file in the MATLAB editor so that you can easily target the errors. These errors will also be reported by checkCodeInterpretable, see Section 3.7.11↓.

3.6.2 Configuring reports folder

By default, any reports are stored as .html files in the default folder that contains the reports. For Windows this is:
    %APPDATA%\Roaming\cc4m\cc4m_reports
For Mac this is:
~/Library/Application Support/cc4m/cc4m_reports
For Linux this is:
    ~/.matlab/cc4m/cc4m_reports
From the command line, the folder in which reports are stored can be requested and changed. See 7↓for an overview of the options.

3.6.3 reportFunctions

reportFunctions gives a list of all functions defined in the file, including nested functions and sub functions. For every function, the following data is given:
Note: this does not report declarations of methods whose function is defined in a separate file. For example, the following method definition will be reported:
methods (Static)
    function nrOut = powerSix(nrIn)
        nrOut = nrIn^6;
    end
end
but the next method declaration (with powerSix in a separate function file) will not:
methods (Static)
    nrOut = powerSix(nrIn)
end
Exemption tag: %@ok<RFUNC>

3.6.4 reportVariables

reportVariables provides a list of all variables defined in the file that is checked. For every variable, the following data is given:
Exemption tag: %@ok<RVARI>

3.6.5 reportDependencies

The file may use functions not defined in the file itself. These dependencies and additional information, are listed under reportDependencies.
For every valid dependency, the following is given:
An example of two dependencies as reported by Code Checker for MATLAB is given in Figure 3.12↓.
figure images/dependencies3.png
Figure 3.12 Two examples of reported dependencies
Unknown dependencies can be recognized by the Function source column. A dependency is considered unknown if:
Limitations

Configurable parameters

Exemption tag: %@ok<RDEPE>

3.6.6 reportComplexity

In this report, you can find the cyclomatic complexities of all checked scripts and functions. The cyclomatic complexity is a measure of the number of linearly independent paths through a script or function. Higher cyclomatic complexity generally means more complex code.

Configurable parameters

Exemption tag: %@ok<RCOMP>

3.6.7 reportBinaryExpressions

This report is especially relevant for m-code that will be used for code generation. It reports all binary expressions for which the order of evaluation might matter. For this report, an expression is a binary expression if it uses a binary operator. These operators are: :, ^, ==, <=, >=, ~=, >, <, &, &&, |, ||, +, -, *, .* and /. An expression will be reported by reportBinaryExpressions if any of these are met:
If a variable is accessed for which the datatype could not be reliably obtained, it is also considered a relevant variable when the fourth preference described in Section 3.3.4↑ is set to false. The datatype of variables used in the code are unknown for example for the inputs of the checked main function, or outputs of user-defined function calls. Disabling the preference may lead to fewer (incorrect) results being reported.
Exemption tag: %@ok<BINEX>

3.6.8 reportCellArrays

reportCellArrays reports all expressions that assign or create cell arrays that are not arrays of character arrays or arrays of heterogeneous objects. Cell array assignments where the cells are of unknown type are reported based on a parameter value. Using cell arrays for for example numbers or logicals is often discouraged because it is unnecessary, more difficult to read, or because it leads to poorer performance. By using the fourth preference described in Section 3.3.4↑, you can choose whether or not to ignore cells of unknown datatype for this report. Code Checker for MATLAB cannot reliably determine the datatype of the cell assigned in every case. For the unknown cases, you can choose whether to report them or not. If this is set to false, all results that are reported are violations for which it is certain the assigned cell is not an object nor a character array.
Exemption tag: %@ok<CELAR>

3.6.9 reportComparisons

In this report, all comparisons made with == or ~= are reported if any of its operands may be a non-integer number. Comparing two doubles using == or ~= that are not guaranteed to be whole numbers is not recommended because it can lead to unexpected results. This report lets you inspect the relevant comparisons yourself to make sure the comparisons work as intended. If necessary, you can adjust certain comparisons by adding a tolerance. The code analysis of Code Checker for MATLAB attempts to determine what data types the operands of the comparison have. This can have three different results:
The following example shows what will be reported and what should be used instead:
% Will be reported as a violation:
out = myFcn(in) == sqrt(3);
​
% Instead use:
out = abs(myFcn(in) - sqrt(3)) < 1e-12;
Exemption tag: %@ok<COMPA>

3.6.10 reportMexFiles

This reports the mex-files the checked code depends on, and also reports whether or not the mex-files for the specified platforms are found. This information provides insight into what mex-files are used, and it can also be used to determine whether the code has a chance to work on different platforms.
Configurable parameters
Exemption tag: %@ok<RMEXF>
Up User guide