SonarQube:扫描过程忽略lcov.info [英] SonarQube: Scanning process ignores lcov.info

查看:373
本文介绍了SonarQube:扫描过程忽略lcov.info的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在扫描 ui 项目。

源代码在 typescript中

gulp测试覆盖率生成 .js 文件(然后扫描覆盖率)。 (每个 .ts 文件都会在同一位置旁边得到一个 .js 文件)

gulp test-coverage generates .js files (which are then scanned for coverage). (each .ts file gets a .js file right next to it, in the same location)

我将扫描仪指向 lcov.info 文件,如下所示:

I am pointing the scanner to the lcov.info file as follows:

sonar.javascript.lcov.reportPaths=test-coverage/lcov.info

问题

lcov.info 提供 .js 文件的覆盖范围信息

The lcov.info, provides coverage information for .js files

出于某种原因,SonarQube还提供了 *。ts 文件(尽管在测试覆盖率报告中包含
)。

For some reason, SonarQube also provides coverage information for the *.ts files (although not incorporated in the test coverage report).

为什么?

如果我明确使用

sonar.inclusions=**/*.ts

sonar.language=ts

.js 文件将从覆盖率报告中忽略

the .js files will be ignored from the coverage report

如果我使用

sonar.coverage.exclusions=**/*.ts

并且没有特定的包含物,这将同时导致两者 .ts .js 扫描文件中的错误,最终将导致重复错误(毕竟, .js 文件是由其 .ts 同行。

and no specific inclusions, this will lead to both the .ts and .js files being scanned for errors, which will end up in duplicate errors (after all, .js files are generated by their .ts counterparts.

有什么建议吗?

如果sonarqube随意地使用了 lcov.info 而不是全部,那么整个问题当然就不复存在了。扫描其他文件的计划。)

The whole issue of course would just go away, if sonarqube took litteraly the lcov.info and did not take initiatives about scanning other files.)

推荐答案

如果您的源代码是用TypeScript编写的,则覆盖率报告( lcov.info )必须包含有关TypeScript文件的信息,而不是已编译的JavaScript。在这种情况下,必须使用的属性是 sonar.typescript.lcov.reportPaths

If your source code is written in TypeScript, the coverage report (lcov.info) must contain information about TypeScript files, and not compiled JavaScript. The property you must be using in this case is sonar.typescript.lcov.reportPaths.

您可以签出此示例( https://github.com/SonarSource/SonarTS-example )以获取更多信息详细信息。

You can check out this example (https://github.com/SonarSource/SonarTS-example) to get more details.

这篇关于SonarQube:扫描过程忽略lcov.info的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆