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:ProjectDefinitionFilesUnderSourceControl" true "All files in the project are under source control." "Project:Checks:AllProjectFilesUnderSourceControl" true "All files under source control are in the project." "Project:Checks:AllFilesUnderSourceControlInProject" true "All project folders exist." "Project:Checks:ProjectFoldersExist" true "All project files 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 "Check for project files with unsaved changes." "Project:Checks:UnsavedProjectFiles" false "All derived files in the project are up-to-date." "Project:Checks:OutOfDateDerivedFiles" true "There are no slprj or sfprj folders in the project." "Project:Checks:SLPRJ" true "Model files saved in a different format (MDL or SLX) are added to the project.↵The original files are not currently in the project." "Project:Checks:MDLToSLX"
注意
运行与源代码管理相关的检查需要对存储库进行完整克隆。在 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
以创建完整克隆。
使用 ID
、Passed
和 ProblemFiles
属性获取有关第一项检查的信息。第一项检查通过,没有发现任何问题。所有工程定义文件都在源代码管理之下。
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
输入参数
proj
— 工程
matlab.project.Project
对象
工程,指定为 matlab.project.Project
对象。使用 currentProject
从当前加载的工程创建一个工程对象。
输出参量
checkResults
— 工程检查
ProjectCheckResult
对象数组
工程检查,以带属性的 ProjectCheckResult
对象数组形式返回。
版本历史记录
在 R2020a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)