Code Quality Dashboard - View code quality metrics for projects - MATLAB (original) (raw)

Main Content

View code quality metrics for projects

Since R2023a

Description

Use the Code Quality Dashboard to view project quality metrics, including code analysis, test and code coverage results, and requirements verification status.

Code Quality Dashboard with metric results for a project.

Open the Code Quality Dashboard App

Open a project, then use one of these approaches to open the app:

Examples

expand all

Since R2023a

This example shows how to collect test and requirements metric results and reflect the results in the Code Quality Dashboard.

Open the MATLABShortestPath project.

openProject("MATLABShortestPath");

Open the Code Quality Dashboard.

Run all tests in the project by clicking the Run button run_16.png.

quality-dashboard.png

Since R2023a

This example shows how to collect coverage metric results and reflect the results in the Code Quality Dashboard.

Open the MATLABShortestPath project.

openProject("MATLABShortestPath");

Open the MATLAB Test Manager.

In the toolstrip, click the Code Coverage button coverage_16.png and select Enable code coverage, then set the coverage metric level to MC/DC.

Open the Code Quality Dashboard.

Run tests and collect coverage by clicking the Run button run_16.png.

quality-dashboard-coverage.png

Since R2024a

This example shows how to update, get, and export metrics from the Code Quality Dashboard.

Open the ShortestPath project.

openProject("MATLABShortestPath");

Open the Code Quality Dashboard.

Run the tests in the project, collect coverage for the tests, verify the requirements, and update the metrics in the dashboard.

matlabtest.codequalitydashboard.runTestsAndRefreshData

Get the metrics from the Code Quality Dashboard.

metrics = matlabtest.codequalitydashboard.getMetrics

metrics = struct with fields: ProjectPath: "C:\Users\jdoe\MATLAB\MATLABShortestPath" Metrics: [1×1 struct]

Export the metrics to a JSON file.

filePath = matlabtest.codequalitydashboard.exportMetrics

filePath = "C:\Users\jdoe\MATLAB\MATLABShortestPath\CodeQualityMetrics.json"

Since R2024b

If you have Requirements Toolbox™, you can open the requirement sets in the current project in the Requirements Editor (Requirements Toolbox).

To open the requirement sets, open the Code Quality Dashboard and click the Requirements section.

If you have loaded requirement sets that are not in the current project, a dialog box prompts you to save and close them.

The Requirements Editor (Requirements Toolbox) opens and displays the loaded requirement sets.

Since R2024b

If you have Requirements Toolbox, you can generate a traceability matrix that contains the requirement sets and MATLAB tests in the current project.

To generate the traceability matrix, open the Code Quality Dashboard. Then, in the Requirements section, click the three-dot icon and select Generate Traceability Matrix.

If you have loaded requirement sets that are not in the current project, a dialog box prompts you to save and close them.

The Traceability Matrix window opens and displays the loaded requirement sets on the top and the tests on the left.

The Traceability Matrix window shows the requirements and tests for the Shortest Path project.

For more information about traceability matrices, see Track Requirement Links with a Traceability Matrix (Requirements Toolbox).

Version History

Introduced in R2023a

expand all

The requirements card of Code Quality Dashboard shows a justified status for requirements justified for verification.

Refreshing the Code Quality Dashboard updates the metrics with added or removed test files or test methods. For more information, see Update the Dashboard.

If you have Requirements Toolbox, you can open the requirement sets in the current project by clicking theRequirements section in the dashboard.

If you have Requirements Toolbox, you can generate a traceability matrix that contains the requirement sets and MATLAB tests in the current project. In the dashboard, in theRequirements section, click the three-dot icon and select Generate Traceability Matrix.

If you have Embedded Coder®, you can use the MATLAB Test Manager to collect coverage for generated C/C++ code that you execute in SIL and PIL equivalence tests. View a summary of the coverage results in the Generated Code Coverage section and open an HTML coverage report by clicking the section.

Run tests by using the Run button . Stop the tests from running to completion by clicking the Stop button .

Each section of the Code Quality Dashboard displays a timestamp that indicates when the software collected the results.

When a parent project references other projects, the Code Quality Dashboard collects and displays quality metrics for the parent project and its referenced projects.

See Also

Apps

Functions

Topics