主要内容

runChecks

运行所有工程检查

说明

checkResults = runChecks(proj) 对指定工程运行检查。这些检查会检测工程完整性方面的问题,例如缺失文件、未保存的文件、未进行源代码管理或过期的派生文件。

如果要检查派生文件是否为最新,您必须更新工程依赖关系。对于大型工程来说,这可能非常耗时。要避免检查派生文件,在调用 runChecks 之前不要更新依赖关系。

示例

示例

全部折叠

打开 Times Table App 工程。使用 currentProject 从当前加载的工程创建一个工程对象。

openExample("matlab/TimesTableProjectExample")
proj = currentProject;

对于大型工程,运行除派生文件检查之外的所有工程检查,因为派生文件检查可能很耗时。

checkResults = runChecks(proj)
 checkResults = 

  11×1 ProjectCheckResult array with properties:

    ID
    Description
    Passed
    ProblemFiles

基于 checkResults 数组创建一个表。该表显示派生文件检查未运行。

summary = table(checkResults)
 summary =

  11×3 table

    Passed                                  Description                                                               ID                             
    ______    _______________________________________________________________________    ____________________________________________________________

    true      "All project definition files are under source control"                    "Project:Checks:ProjectDefinitionFilesAreUnderSourceControl"
    true      "All project files are under source control"                               "Project:Checks:AllProjectFilesUnderSourceControl"          
    false     "All files under source control are in the project"                        "Project:Checks:AllFilesUnderSourceControlAreInProject"     
    false     "All project files and folders exist on the file system"                   "Project:Checks:ProjectFilesExist"                          
    true      "All project folders on the MATLAB search path are on the project path"    "Project:Checks:ProjectPath"                                
    true      "All projects in sub-folders are referenced by this project"               "Project:Checks:ReferencedSubprojects"                      
    true      "No duplicates or missing default labels"                                  "Project:Checks:MissingOrDuplicateLabelsInProject"          
    true      "No out of date P-code files"                                              "Project:Checks:OutdatedPcodedFiles"                        
    true      "No project files with unsaved changes"                                    "Project:Checks:UnsavedProjectFiles"                        
    true      "No models in the project have mismatching file formats"                   "Project:Checks:MDLToSLX"                                   
    true      "No slprj or sfprj folders in the project"                                 "Project:Checks:SLPRJ"                                          
 

注意

运行与源代码管理相关的检查需要对存储库进行完整克隆。在 CI/CD 管道中,一些存储库托管平台(如 GitLab®)默认对每个作业采用深度为 50 的浅克隆。将克隆和提取深度设置为 0 以创建完整克隆。

打开 Times Table App 工程。使用 currentProject 从当前加载的工程创建一个工程对象。

openExample("matlab/TimesTableProjectExample")
proj = currentProject;

如果要检查派生文件是否为最新,您必须首先更新工程依赖关系。

updateDependencies(proj);

运行所有工程检查。

checkResults = runChecks(proj)
 checkResults = 

  11×1 ProjectCheckResult array with properties:

    ID
    Description
    Passed
    ProblemFiles

注意

运行与源代码管理相关的检查需要对存储库进行完整克隆。在 CI/CD 管道中,一些存储库托管平台(如 GitLab)默认对每个作业采用深度为 50 的浅克隆。将克隆和提取深度设置为 0 以创建完整克隆。

使用 IDPassedProblemFiles 属性获取有关第一项检查的信息。第一项检查通过,没有发现任何问题。所有工程定义文件都在源代码管理之下。

id = checkResults(1).ID
status = checkResults(1).Passed
problems = checkResults(1).ProblemFiles
id = 

    "Project:Checks:ProjectDefinitionFilesUnderSourceControl"


status =

  logical

   1


problems = 

  0×0 empty string array

对派生文件的检查通过,未检测到任何问题文件。所有派生文件均为最新的。

id = checkResults(9).ID
status = checkResults(9).Passed
problems = checkResults(1).ProblemFiles
id = 

    "Project:Checks:OutOfDateDerivedFiles"


status =

  logical

   1


problems = 

  0×0 empty string array

输入参数

全部折叠

工程,指定为 matlab.project.Project 对象。使用 currentProject 从当前加载的工程创建一个工程对象。

输出参量

全部折叠

工程检查,以带属性的 ProjectCheckResult 对象数组形式返回。

版本历史记录

在 R2020a 中推出

全部展开