SonarQube:在覆盖率报告期间忽略文件 [英] SonarQube: Ignore files during coverage report
问题描述
我想为 ui
项目提供一份覆盖率报告。
I want to provide a coverage report for a ui
project.
该项目主要由 .ts
文件受版本控制。
The project mainly consists of .ts
files which under version control.
gulp
命令用于检查覆盖率,生成 .js
文件,然后检查覆盖率。 (以及一份覆盖报告,该报告仅仅报告这些文件)
The gulp
command used to check coverage, generates .js
files which are then checked for coverage. (and a coverage report that ... reports only on those files)
.js
文件不受版本控制,并且在生成时与 .ts
文件混合(即,只要有 .ts code>文件,其旁边将生成一个
.js
文件。)
The .js
files are not under version control and, when produced are intermingled with the .ts
files (i.e., wherever there is a .ts
file, a .js
file will be generated next to it).
以下问题:
当 sonarqube
生成覆盖率报告时,请参见上述报告(由 sonar.javascript.lcov.reportPaths
),添加 .ts
文件(当然,其中的 0.0%
覆盖率),这会破坏实际的cov值。
When sonarqube
generates coverage report, to my report above (pointed to by sonar.javascript.lcov.reportPaths
), the .ts
files are added (which of course have 0.0%
coverage) and this breaks the actual cov value.
有没有一种方法/模式来指示声纳法:
Is there a way / pattern to instruct sonarqube to:
a)在 .ts
文件上执行代码分析
a) perform code analysis on .ts
files
b)忽略生成覆盖率报告时全部 .ts
个文件?
推荐答案
只需在项目文档。
忽略代码覆盖率
您可以防止单元测试将某些文件考虑为代码
的覆盖范围。
You can prevent some files from being taken into account for code coverage by unit tests.
为此,请转到管理>常规设置>分析范围>
代码覆盖率并设置覆盖率排除项属性
To do so, go to Administration > General Settings > Analysis Scope > Code Coverage and set the Coverage Exclusions property
在 sonar-project.properties
文件中还可以使用以下指令:
There is also the following directive that can be used in the sonar-project.properties
file:
sonar.coverage.exclusions
这篇关于SonarQube:在覆盖率报告期间忽略文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!