Main Content

CodeCompatibilityAnalysis

Code compatibility analysis results

Description

Use the CodeCompatibilityAnalysis object to save or report results from a code compatibility analysis. A list of all checks performed by the MATLAB® Code Analyzer, including checks for compatibility issues, can be found here, Index of Code Analyzer Checks.

Creation

Create a code compatibility analysis object using the analyzeCodeCompatibility function.

Properties

expand all

This property is read-only.

Date of code compatibility analysis, returned as a datetime scalar.

Data Types: datetime

This property is read-only.

Version of MATLAB used for code compatibility analysis, returned as a string scalar.

Data Types: string

This property is read-only.

List of files analyzed by for code compatibility, returned as a string array.

Data Types: string

This property is read-only.

List of the checks performed and the frequency of occurrence in the analyzed files, returned as a table with these columns.

Table ColumnDescription

Identifier

Identifier for MATLAB code analyzer messages.

Description

Description of check. For example, Use a newline, semicolon, or comma before this statement or STRMATCH is not recommended. Use STRNCMP or VALIDATESTRING instead. Description is same as code analyzer message.

Documentation

Command to open more information in documentation.

Severity

Severity of check. For example, Error or Warning. Errors might indicate syntax errors or use of functionality that is no longer supported. Warnings might indicate opportunities to improve your code.

NumOccurrences

In analyzed code, total number of occurrences where a particular check is flagged.

NumFiles

In analyzed code, number of files where a particular check is flagged.

Data Types: table

This property is read-only.

Recommendations to update code based on the analysis, returned as a table with the following columns.

Table ColumnDescription

Identifier

Identifier for MATLAB code analyzer messages.

Description

Description of check. For example, Use a newline, semicolon, or comma before this statement or STRMATCH is not recommended. Use STRNCMP or VALIDATESTRING instead. Description is same as code analyzer message.

Documentation

Command to open more information in documentation.

Severity

Severity of check. For example, Error or Warning. Errors might indicate syntax errors or use of functionality that is no longer supported. Warnings might indicate opportunities to improve your code.

FileName of file that contains flagged check.
LineNumberLine number indicating location in file of flagged check.
ColumnRangeColumn range indicating location in file of flagged check.

Data Types: table

Examples

collapse all

Create code compatibility analysis results for code in your current folder and subfolders.

r = analyzeCodeCompatibility
r = 

  CodeCompatibilityAnalysis with properties:

               Date: 20-Apr-2017 15:06:06
      MATLABVersion: "R2017b"
              Files: [92×1 string]
    ChecksPerformed: [299×6 table]
    Recommendations: [28×7 table]

Analyze the code again and omit subfolders from the analysis.

r = analyzeCodeCompatibility('IncludeSubfolders',false)
r = 

  CodeCompatibilityAnalysis with properties:

               Date: 20-Apr-2017 15:06:56
      MATLABVersion: "R2017b"
              Files: [5×1 string]
    ChecksPerformed: [299×6 table]
    Recommendations: [1×7 table]

Version History

Introduced in R2017b