【问题标题】:Issue when trying to import Jacoco code coverage to SonarQube: Cannot import coverage information for file, coverage data is invalid尝试将 Jacoco 代码覆盖率导入 SonarQube 时出现问题:无法导入文件的覆盖率信息,覆盖率数据无效
【发布时间】:2019-10-01 05:41:01
【问题描述】:

我在尝试将 Jacoco 代码覆盖率导入 SonarQube 时遇到了一些问题。

我正在使用带有 Jacoco 的 SonarQube 来导入测试覆盖率结果 (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 Scanner 3.3.0.1492,SonarQube 服务器 7.5.0。

【问题讨论】:

    标签: kotlin sonarqube jacoco


    【解决方案1】:

    在 Google 中按关键字搜索 sonarqube kotlin jacoco

    is out of range in the file

    揭示了以下页面 https://community.sonarsource.com/t/sonar-kotlin-coverage-fails-due-to-line-is-out-of-range-errors/3201/18 ,其中指出问题已在 JaCoCo 版本 0.8.3 中得到修复,其中包含指向页面 https://github.com/jacoco/jacoco/issues/763 的链接,该页面又包含对问题的非常富有表现力的解释,包括解释它为什么会影响 SonarQube .

    因此,请确保您使用 JaCoCo 版本 0.8.3 或更好的最新版本,即截至 2021 年 9 月 8 日的 0.8.7

    【讨论】:

      猜你喜欢
      • 2021-03-03
      • 2017-01-25
      • 1970-01-01
      • 1970-01-01
      • 2019-09-12
      • 1970-01-01
      • 2018-11-13
      • 2017-05-31
      • 2016-11-11
      相关资源
      最近更新 更多