尝试将Jacoco代码coverage导入SonarQube时出现问题:无法导入文件的coverage信息,coverage数据无效 [英] Issue when trying to import Jacoco code coverage to SonarQube: Cannot import coverage information for file, coverage data is invalid

查看:420
本文介绍了尝试将Jacoco代码coverage导入SonarQube时出现问题:无法导入文件的coverage信息,coverage数据无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将Jacoco代码覆盖率导入SonarQube时遇到一些问题.

我正在将SonarQube与Jacoco一起用于导入测试覆盖率结果( https://docs.sonarqube.org/display/PLUG/Java+Unit+Tests+and+Coverage+Results+Import ).一切运行良好,直到我以某种方法 forEach 被阻止为止.

ERROR: Cannot import coverage information for file, coverage data is invalid. 
java.lang.IllegalStateException: Line 29 is out of range in the file (lines: 28)

如果我删除 forEach 文件,则可以正确生成测试覆盖率,但是使用 forEach ,我得到0%覆盖率.

仅当我将其与sonarqube集成时,才会发生这种情况,如果我在本地运行jacoco,则效果很好.

我们使用SonarQube扫描仪3.3.0.1492,SonarQube服务器7.5.0.

解决方案

在Google中通过关键字sonarqube kotlin jacoco

进行搜索

is out of range in the file

显示以下页面 https://的链接github.com/jacoco/jacoco/issues/763 ,它反过来又包含了问题的表达方式,包括对它为何影响SonarQube的解释.

因此,请确保使用JaCoCo版本0.8.3或更好的最新版本0.8.4.

I'm having some issues when trying to import Jacoco code coverage to SonarQube.

I am using SonarQube with Jacoco for importing test coverage results (https://docs.sonarqube.org/display/PLUG/Java+Unit+Tests+and+Coverage+Results+Import). Everything has worked well until i have forEach block in some method.

ERROR: Cannot import coverage information for file, coverage data is invalid. 
java.lang.IllegalStateException: Line 29 is out of range in the file (lines: 28)

If I remove forEach file then test coverage is correctly generated, but with forEach I get 0% coverage.

This happens only when i integrate it with sonarqube, if i run jacoco locally it works perfectly.

We use SonarQube Scanner 3.3.0.1492, SonarQube server 7.5.0.

解决方案

Search in Google by keywords sonarqube kotlin jacoco and

is out of range in the file

reveals following page https://community.sonarsource.com/t/sonar-kotlin-coverage-fails-due-to-line-is-out-of-range-errors/3201/18 , which states that problem was fixed in JaCoCo version 0.8.3 And which contains link to page https://github.com/jacoco/jacoco/issues/763 , which in its turn contains quite expressive explanation of problem, including explanations of why it affects SonarQube.

So make sure that you use JaCoCo version 0.8.3 or even better latest 0.8.4.

这篇关于尝试将Jacoco代码coverage导入SonarQube时出现问题:无法导入文件的coverage信息,coverage数据无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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