Main Content

matlabtest.codequalitydashboard.exportMetrics

Export Code Quality Dashboard metrics to JSON

Since R2024a

    Description

    filePath = matlabtest.codequalitydashboard.exportMetrics exports the metric results from the Code Quality Dashboard to a JSON file.

    example

    filePath = matlabtest.codequalitydashboard.exportMetrics(Name=Value) specifies options using one or more name-value arguments.

    example

    Examples

    collapse all

    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.

    codeQualityDashboard

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

    matlabtest.codequalitydashboard.runTestsAndRefreshData
    pathLength = 
    3
    

    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"
    

    This example shows how to specify the file name when you export metrics from the Code Quality Dashboard.

    Open the ShortestPath project.

    openProject("MATLABShortestPath");

    Open the Code Quality Dashboard.

    codeQualityDashboard

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

    matlabtest.codequalitydashboard.runTestsAndRefreshData

    Export the metrics to a JSON file called CQDMetrics.

    filePath = matlabtest.codequalitydashboard.exportMetrics( ...
        Filename="CQDMetrics")
    filePath = 
    "C:\Users\jdoe\MATLAB\MATLABShortestPath\CQDMetrics.json"
    

    Input Arguments

    collapse all

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: Filename="myMetrics"

    JSON file name, specified as a string scalar or a character vector. If you do not specify this name-value argument, the software names the file CodeQualityMetrics.

    Example: Filename="myMetrics"

    Folder in which to store the JSON file, specified as a string scalar or character vector. You can specify the folder by using a relative or absolute file path. If you do not specify this name-value argument, the software stores the JSON file in the current folder.

    Example: FolderPath="reports"

    Output Arguments

    collapse all

    File path to the JSON file, returned as a string scalar. The software returns the file path as an absolute path unless you specify a relative path by using the FolderPath argument.

    Version History

    Introduced in R2024a