【问题标题】:Error with SonarQube Visual Studio Code Coverage ImportSonarQube Visual Studio 代码覆盖导入错误
【发布时间】:2016-08-19 08:58:53
【问题描述】:

我在从一种特定解决方案导入 Coverage 结果时看到错误。其他人似乎工作正常。我一直在使用 5.1 版的 C# 插件,我刚刚尝试了 5.2 RC,但仍然看到同样的问题。

该错误似乎与源文件的行数少于覆盖文件似乎指示的行数有关。我在这里看到了一个类似的问题,看起来它已经解决了,但对我来说不是......;

https://groups.google.com/forum/#!topic/sonarqube/Xju6ichZe_k

您能提供的任何帮助或指导将不胜感激,因为这是我从 SonarQube 获取有用信息的最后一步。


错误是;

java.lang.IllegalStateException:无法为第 12 行创建度量 文件 'E:/b/3/_work/25/s/Maples.eServices.UI/Maples.eServices.UI.Services/TodayNotification/AggregatedEmailModels/ContactWithChanges.cs' 9行

2016-04-25T18:42:08.8051671Z 19:42:08.617 信息 - 传感器 org.sonar.plugins.csharp.CSharpSensor (完成) |时间=3703ms
2016-04-25T18:42:08.8051671Z 19:42:08.617 信息 - 传感器 org.sonar.plugins.csharp.CSharpCodeCoverageProvider$CSharpCoverageReportImportSensor 2016-04-25T18:42:08.8051671Z 19:42:08.617 信息 - 解析视觉 工作室覆盖率 XML 报告 E:\b\3_work\25\TestResults\svctfsbuild_KYTFS15BLD02 2016-04-25 19_38_27\In\KYTFS15BLD02\svctfsbuild_KYTFS15BLD02 2016-04-25 19_37_19.coveragexml 2016-04-25T18:42:08.9145352Z 19:42:08.773 信息 - 将此代码覆盖率报告添加到缓存以供以后重用:E:\b\3_work\25\TestResults\svctfsbuild_KYTFS15BLD02 2016-04-25 19_38_27\In\KYTFS15BLD02\svctfsbuild_KYTFS15BLD02 2016-04-25 19_37_19.coveragexml 2016-04-25T18:42:09.5707468Z 信息:

2016-04-25T18:42:09.5707468Z 信息:执行失败
2016-04-25T18:42:09.5707468Z 信息:

2016-04-25T18:42:09.5707468Z 总时间:1:30.185s
2016-04-25T18:42:09.6801267Z 最终内存:10M/235M
2016-04-25T18:42:09.6801267Z 信息:

2016-04-25T18:42:09.6801267Z ##[error]ERROR:Sonar runner 期间出错 执行 2016-04-25T18:42:09.6801267Z ##[error]org.sonar.runner.impl.RunnerException: 无法执行声纳 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
2016-04-25T18:42:09.6801267Z ##[错误]at java.security.AccessController.doPrivileged(本机方法)
2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.runner.api.Runner.execute(Runner.java:100)
2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.runner.Main.executeTask(Main.java:70)
2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.runner.Main.execute(Main.java:59)
2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.runner.Main.main(Main.java:53)
2016-04-25T18:42:09.6801267Z ##[错误]引起: java.lang.IllegalStateException:无法为第 12 行创建度量 文件 'E:/b/3/_work/25/s/Maples.eServices.UI/Maples.eServices.UI.Services/TodayNotification/AggregatedEmailModels/ContactWithChanges.cs' 9 行 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.sensor.coverage.CoverageExclusions.validateMaxLine(CoverageExclusions.java:158) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.sensor.coverage.CoverageExclusions.validate(CoverageExclusions.java:129) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:204) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.plugins.dotnet.tests.CoverageReportImportSensor.analyze(CoverageReportImportSensor.java:103) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.plugins.dotnet.tests.CoverageReportImportSensor.analysis(CoverageReportImportSensor.java:74) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:102)
2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:185) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:120) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:264) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:259) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:257) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:249) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.scan.ProjectScanContainer.startComponents(ProjectScanContainer.java:127) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:120) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.task.ScanTask.execute(ScanTask.java:55)
2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:120) 2016-04-25T18:42:09.6801267Z ##[错误]at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:122) 2016-04-25T18:42:09.6957435Z ##[错误]at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
2016-04-25T18:42:09.6957435Z ##[错误]at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:79)
2016-04-25T18:42:09.6957435Z ##[错误]at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48) 2016-04-25T18:42:09.6957435Z ##[错误]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2016-04-25T18:42:09.6957435Z ##[错误]at sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)
2016-04-25T18:42:09.6957435Z ##[错误]at sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)
2016-04-25T18:42:09.6957435Z ##[错误]at java.lang.reflect.Method.invoke(未知来源)
2016-04-25T18:42:09.6957435Z ##[错误]at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87) 2016-04-25T18:42:09.6957435Z ##[错误]... 9 更多
2016-04-25T18:42:09.6957435Z ##[错误]错误:
2016-04-25T18:42:09.6957435Z ##[错误]错误:重新运行 SonarQube Runner 使用 -X 开关启用完整的调试日志记录。
2016-04-25T18:42:09.6957435Z ##[错误]SonarQube 扫描仪没有 成功完成 2016-04-25T18:42:09.6957435Z 19:42:09.617 创建摘要降价文件... 2016-04-25T18:42:09.6957435Z ##[错误]后处理失败。退出代码:1 2016-04-25T18:42:09.8207681Z ##[错误]收到意外退出代码 来自批处理文件:1

coveragexml 文件的相关部分是;

     <function id="215992" token="0x6000cce" name="get_ContactId()" type_name="ContactWithChanges" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="3" lines_covered="0" lines_partially_covered="0" lines_not_covered="1">
      <ranges>
        <range source_id="213" covered="no" start_line="5" start_column="26" end_line="5" end_column="27" />
        <range source_id="213" covered="no" start_line="5" start_column="28" end_line="5" end_column="32" />
      </ranges>
    </function>
    <function id="216018" token="0x6000ccf" name="set_ContactId(int)" type_name="ContactWithChanges" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="3" lines_covered="0" lines_partially_covered="0" lines_not_covered="1">
      <ranges>
        <range source_id="213" covered="no" start_line="5" start_column="31" end_line="5" end_column="32" />
        <range source_id="213" covered="no" start_line="5" start_column="33" end_line="5" end_column="37" />
      </ranges>
    </function>
    <function id="216032" token="0x6000cd0" name="get_DisplayName()" type_name="ContactWithChanges" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="3" lines_covered="0" lines_partially_covered="0" lines_not_covered="1">
      <ranges>
        <range source_id="213" covered="no" start_line="5" start_column="33" end_line="5" end_column="37" />
      </ranges>
    </function>
    <function id="216058" token="0x6000cd1" name="set_DisplayName(string)" type_name="ContactWithChanges" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="3" lines_covered="0" lines_partially_covered="0" lines_not_covered="14">
      <ranges>
        <range source_id="213" covered="no" start_line="6" start_column="36" end_line="6" end_column="37" />
        <range source_id="213" covered="no" start_line="6" start_column="38" end_line="6" end_column="42" />
        <range source_id="213" covered="no" start_line="14" start_column="7" end_line="20" end_column="10" />
      </ranges>
    </function>
    <function id="216072" token="0x6000cd2" name="ContactWithChanges()" type_name="ContactWithChanges" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="4" lines_covered="0" lines_partially_covered="0" lines_not_covered="15">
      <ranges>
        <range source_id="213" covered="no" start_line="6" start_column="38" end_line="6" end_column="42" />
        <range source_id="213" covered="no" start_line="12" start_column="5" end_line="12" end_column="41" />
        <range source_id="213" covered="no" start_line="14" start_column="7" end_line="20" end_column="10" />
      </ranges>
    </function>
    <source_file id="213" path="E:\b\3\_work\25\s\Maples.eServices.UI\Maples.eServices.UI.Services\TodayNotification\AggregatedEmailModels\ContactWithChanges.cs">
    </source_file>

源代码是;

namespace Maples.eServices.UI.Services.TodayNotification.AggregatedEmailModels
{
  public class ContactWithChanges
  {
    public int ContactId { get; set; }
    public string DisplayName { get; set; }
  }
}

【问题讨论】:

    标签: .net sonarqube


    【解决方案1】:

    我的团队升级到 sonarqube 6.2 时发生了这种情况。 我们正在使用 Jenkins 来构建和运行分析。 我擦拭了工作区并重新运行作业,一切都再次成功运行。

    随机猜测:
    可能是由于覆盖扫描现在很流畅(加法)。 取出source code

    /**
     * This class is used to report code coverage on files.
     * 
     * Example:
     * 
     * <pre>
     *   sensorContext.newCoverage().onFile(file)
           .lineHits(1, 2)
           .lineHits(2, 5)
           .lineHits(3, 0)
           . ...
           .conditions(3, 4, 2)
           .conditions(12, 2, 2)
           . ...
           .save();
     *     
     * </pre>
     * 
     * Since 6.2 you can save several reports for the same file and reports will be merged using the following "additive" strategy:
     * <ul>
     *   <li>Line hits are cumulated</li>
     *   <li>We keep the max for condition coverage. Examples: 2/4 + 2/4 = 2/4, 2/4 + 3/4 = 3/4</li>
     * </ul>
     * 
     * @since 5.2
    

    【讨论】:

      猜你喜欢
      • 2017-01-25
      • 1970-01-01
      • 2016-09-07
      • 2019-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-13
      • 1970-01-01
      相关资源
      最近更新 更多