当前位置: 首页 > 知识库问答 >
问题:

Sonarqube 5.1.2带sonar-runner 2.4 doesnt display Groovy cobertura report

宗政霄
2023-03-14

我有以下设置:

  1. Sonarqube v5.1.2
  2. 声纳转轮v2.4
  3. Sonarqube v1.6.3的Cobertura插件
  4. Sonarqube v1.2的Groovy插件

都有最新的版本。

ParentProject
|-sonar-project.properties
|- Grails Project A
|  |-sonar-project.properties
sonar.projectKey=ParentProject
sonar.projectName=Parent Project SONARQUBE
sonar.projectVersion=1.0

sonar.scm.url=scm:svn:https://server/svn/nv/frontend/grails/trunk
sonar.scm.provider=svn
sonar.language=grvy
sonar.core.codeCoveragePlugin=cobertura
sonar.grvy.coveragePlugin=cobertura
sonar.groovy.cobertura.reportPath=target/test-reports/cobertura/coverage.xml
sonar.cobertura.reportPath=target/test-reports/cobertura/coverage.xml
sonar.sourceEncoding=UTF-8
sonar.web.file.suffixes=gsp

sonar.modules= ProjectA

# Settings for servicemodel#
ProjectA.sonar.projectBaseDir=./ProjectA
sonar.modules = projectA-groovymodule, projectA-javascriptmodule, projectA-webmodule

projectA-groovymodule.sonar.projectBaseDir=.
projectA-groovymodule.sonar.language=grvy
projectA-groovymodule.sonar.sources=grails-app/services,grails-app/controllers,grails-app/domain,grails-app/taglib,src/groovy
projectA-groovymodule.sonar.tests=test/unit,test/integration
projectA-groovymodule.sonar.junit.reportsPath=target/test-reports
projectA-groovymodule.sonar.cobertura.reportPath = target/test-reports/cobertura/coverage.xml
projectA-groovymodule.sonar.groovy.cobertura.reportPath=target/test-reports/cobertura/coverage.xml
projectA-groovymodule.sonar.grvy.coveragePlugin=cobertura

projectA-javascriptmodule.sonar.projectBaseDir=.
projectA-javascriptmodule.sonar.language=js
projectA-javascriptmodule.sonar.sources=grails-app, web-app/js
projectA-javascriptmodule.sonar.exclusions=web-app/js/lib/**/*

projectA-webmodule.sonar.projectBaseDir=.
projectA-webmodule.sonar.language=web
projectA-webmodule.sonar.sources=grails-app/views
D:\Build\ParentProject>sonar-runner
D:\Apps\sonar-runner-2.4
SonarQube Runner 2.4
Java 1.7.0_51 Oracle Corporation (64-bit)
Windows Server 2008 R2 6.1 amd64
INFO: Runner configuration file: D:\Apps\sonar-runner-2.4\conf\sonar-runner.properties
INFO: Project configuration file: D:\Build\ParentProject\sonar-project.properties
INFO: Default locale: "en_EN", source code encoding: "UTF-8"
INFO: Work directory: D:\Build\ParentProject\.\.sonar
INFO: SonarQube Server 5.1.2
16:05:40.180 INFO  - Load global repositories
16:05:40.644 INFO  - Load global repositories (done) | time=470ms
16:05:40.689 INFO  - Server id: 20150930161227
16:05:40.696 INFO  - User cache: d:\gebruikers\user\.sonar\cache
16:05:40.888 INFO  - Install plugins
16:05:43.829 INFO  - Install JDBC driver
16:05:44.278 INFO  - Create JDBC datasource for jdbc:jtds:sqlserver://dbserver:port/db;instance=instance;SelectMethod=Cursor
16:05:48.516 INFO  - Initializing Hibernate
16:05:56.529 INFO  - Load project repositories
16:05:57.659 INFO  - Load project repositories (done) | time=1130ms
16:05:57.822 INFO  - Load project settings
16:05:59.033 INFO  - Load technical debt model
16:05:59.085 INFO  - Apply project exclusions
16:06:01.353 INFO  - -------------  Scan projectA-groovymodule
16:06:01.360 INFO  - Load module settings
16:06:01.731 INFO  - Language is forced to grvy
16:06:01.734 INFO  - Load rules
16:06:03.153 INFO  - Base dir: D:\Build\ParentProject\ProjectA
16:06:03.156 INFO  - Working dir: D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-groovymodule
16:06:03.158 INFO  - Source paths: grails-app/services, grails-app/controllers, grails-app/domain, grails-app/taglib, src/groovy
16:06:03.159 INFO  - Test paths: test/unit, test/integration
16:06:03.160 INFO  - Source encoding: UTF-8, default locale: en_EN
16:06:03.161 INFO  - Index files
16:06:03.179 INFO  - Excluded sources:
16:06:03.181 INFO  -   web-app/js/jquery/**
16:06:03.314 INFO  - 18 files indexed
16:06:03.315 INFO  - 0 files ignored because of inclusion/exclusion patterns
16:06:03.648 INFO  - Quality profile for grvy: profile
16:06:04.398 INFO  - Sensor Lines Sensor
16:06:04.512 INFO  - Sensor Lines Sensor (done) | time=114ms
16:06:04.513 INFO  - Sensor QProfileSensor
16:06:04.522 INFO  - Sensor QProfileSensor (done) | time=9ms
16:06:04.525 INFO  - Sensor InitialOpenIssuesSensor
16:06:04.682 INFO  - Sensor InitialOpenIssuesSensor (done) | time=157ms
16:06:04.683 INFO  - Sensor ProjectLinksSensor
16:06:04.696 INFO  - Sensor ProjectLinksSensor (done) | time=13ms
16:06:04.697 INFO  - Sensor VersionEventsSensor
16:06:04.716 INFO  - Sensor VersionEventsSensor (done) | time=19ms
16:06:04.717 INFO  - Sensor CodeNarc
16:06:04.718 INFO  - Executing CodeNarc
16:06:05.580 INFO  - Loaded properties file in 67ms; 346 rules
16:06:05.641 INFO  - Loading ruleset from [file:D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-groo
vymodule\codenarc\profile.xml]
16:06:07.175 INFO  - RuleSet configuration properties file [codenarc.properties] not found.
16:06:09.625 INFO  - No custom message bundle found for [codenarc-messages]. Using default messages.
16:06:11.759 INFO  - Report file [D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-groovymodule\coden
arc\report1.xml] created.
CodeNarc completed: (p1=0; p2=2; p3=2) 4140ms
16:06:11.764 INFO  - Loaded properties file in 1ms; 346 rules
16:06:11.765 INFO  - Loading ruleset from [file:D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-groo
vymodule\codenarc\profile.xml]
16:06:11.869 INFO  - RuleSet configuration properties file [codenarc.properties] not found.
16:06:15.067 INFO  - No custom message bundle found for [codenarc-messages]. Using default messages.
16:06:17.707 INFO  - Report file [D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-groovymodule\coden
arc\report2.xml] created.
CodeNarc completed: (p1=0; p2=17; p3=13) 3298ms
16:06:17.710 INFO  - Loaded properties file in 1ms; 346 rules
16:06:17.711 INFO  - Loading ruleset from [file:D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-groo
vymodule\codenarc\profile.xml]
16:06:17.826 INFO  - RuleSet configuration properties file [codenarc.properties] not found.
16:06:17.837 INFO  - No custom message bundle found for [codenarc-messages]. Using default messages.
16:06:18.969 INFO  - Report file [D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-groovymodule\coden
arc\report3.xml] created.
CodeNarc completed: (p1=0; p2=0; p3=0) 127ms
16:06:18.972 INFO  - Loaded properties file in 1ms; 346 rules
16:06:18.973 INFO  - Loading ruleset from [file:D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-groo
vymodule\codenarc\profile.xml]
16:06:19.040 INFO  - RuleSet configuration properties file [codenarc.properties] not found.
16:06:19.167 INFO  - No custom message bundle found for [codenarc-messages]. Using default messages.
16:06:19.532 INFO  - Report file [D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-groovymodule\coden
arc\report4.xml] created.
CodeNarc completed: (p1=0; p2=0; p3=2) 195ms
16:06:19.537 INFO  - Loaded properties file in 1ms; 346 rules
16:06:19.540 INFO  - Loading ruleset from [file:D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-groo
vymodule\codenarc\profile.xml]
16:06:19.586 INFO  - RuleSet configuration properties file [codenarc.properties] not found.
16:06:19.774 INFO  - No custom message bundle found for [codenarc-messages]. Using default messages.
16:06:20.092 INFO  - Report file [D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-groovymodule\coden
arc\report5.xml] created.
CodeNarc completed: (p1=0; p2=4; p3=38) 233ms
16:06:20.765 INFO  - Sensor CodeNarc (done) | time=16048ms
16:06:20.766 INFO  - Sensor GroovySensor
16:06:21.158 INFO  - GMetrics completed: 237ms
16:06:21.203 INFO  - Sensor GroovySensor (done) | time=437ms
16:06:21.204 INFO  - Sensor Groovy CoberturaSensor
16:06:21.205 INFO  - Analyzing Cobertura report: target/test-reports/cobertura/coverage.xml
16:06:21.377 INFO  - Sensor Groovy CoberturaSensor (done) | time=173ms
16:06:21.378 INFO  - Sensor SCM Sensor
16:06:21.414 INFO  - Sensor SCM Sensor (done) | time=36ms
16:06:21.415 INFO  - Sensor GroovySurefireSensor
16:06:21.417 INFO  - parsing D:\Build\ParentProject\ProjectA\target\test-reports
16:06:21.418 INFO  - Sensor GroovySurefireSensor (done) | time=3ms
16:06:21.419 INFO  - Sensor CPD Sensor
16:06:21.420 INFO  - DefaultCpdEngine is used for grvy
16:06:21.421 INFO  - Cross-project analysis enabled
16:06:21.760 INFO  - Sensor CPD Sensor (done) | time=341ms
16:06:21.769 INFO  - No quality gate is configured.
16:06:21.853 INFO  - Compare to previous analysis (2015-10-01)
16:06:21.861 INFO  - Compare over 30 days (2015-09-01, analysis of Mon Aug 31 01:18:52 CEST 2015)
16:06:21.864 INFO  - Compare over 21 days (2015-09-10, analysis of Wed Sep 09 01:18:12 CEST 2015)
16:06:22.556 INFO  - Execute decorators...
16:06:24.684 INFO  - -------------  Scan ProjectA-javascriptmodule
16:06:24.686 INFO  - Load module settings
16:06:24.727 INFO  - Language is forced to js
16:06:24.744 INFO  - Base dir: D:\Build\ParentProject\ProjectA
16:06:24.745 INFO  - Working dir: D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-javascriptmodule
16:06:24.746 INFO  - Source paths: grails-app, web-app/js
16:06:24.747 INFO  - Source encoding: UTF-8, default locale: en_EN
16:06:24.748 INFO  - Index files
16:06:24.749 INFO  - Excluded sources:
16:06:24.750 INFO  -   web-app/js/lib/**/*
16:06:24.815 INFO  - 9 files indexed
16:06:24.816 INFO  - 3 files ignored because of inclusion/exclusion patterns
16:06:24.903 INFO  - Quality profile for js: ParentProject
16:06:24.948 INFO  - Sensor Lines Sensor
16:06:24.952 INFO  - Sensor Lines Sensor (done) | time=4ms
16:06:24.953 INFO  - Sensor QProfileSensor
16:06:24.954 INFO  - Sensor QProfileSensor (done) | time=1ms
16:06:24.954 INFO  - Sensor InitialOpenIssuesSensor
16:06:25.024 INFO  - Sensor InitialOpenIssuesSensor (done) | time=70ms
16:06:25.031 INFO  - Sensor ProjectLinksSensor
16:06:25.040 INFO  - Sensor ProjectLinksSensor (done) | time=9ms
16:06:25.043 INFO  - Sensor VersionEventsSensor
16:06:25.096 INFO  - Sensor VersionEventsSensor (done) | time=53ms
16:06:25.097 INFO  - Sensor JavaScriptSquidSensor
16:06:25.101 INFO  - 9 source files to be analyzed
16:06:26.722 INFO  - Sensor JavaScriptSquidSensor (done) | time=1625ms
16:06:26.723 INFO  - 9/9 source files have been analyzed
16:06:26.724 INFO  - Sensor SCM Sensor
16:06:26.732 INFO  - Sensor SCM Sensor (done) | time=8ms
16:06:26.733 INFO  - Sensor org.sonar.plugins.javascript.lcov.UTCoverageSensor@4d2f36b2
16:06:26.733 INFO  - Sensor org.sonar.plugins.javascript.lcov.UTCoverageSensor@4d2f36b2 (done) | time=0ms
16:06:26.734 INFO  - Sensor org.sonar.plugins.javascript.lcov.ITCoverageSensor@56b007b4
16:06:26.735 INFO  - Sensor org.sonar.plugins.javascript.lcov.ITCoverageSensor@56b007b4 (done) | time=1ms
16:06:26.735 INFO  - Sensor CPD Sensor
16:06:26.736 INFO  - DefaultCpdEngine is used for js
16:06:26.736 INFO  - Cross-project analysis enabled
16:06:27.151 INFO  - Sensor CPD Sensor (done) | time=416ms
16:06:27.153 INFO  - No quality gate is configured.
16:06:27.159 INFO  - Compare to previous analysis (2015-10-01)
16:06:27.161 INFO  - Compare over 30 days (2015-09-01, analysis of Mon Aug 31 01:18:52 CEST 2015)
16:06:27.163 INFO  - Compare over 21 days (2015-09-10, analysis of Wed Sep 09 01:18:12 CEST 2015)
16:06:27.518 INFO  - Execute decorators...
16:06:27.916 INFO  - -------------  Scan ProjectA-webmodule
16:06:27.918 INFO  - Load module settings
16:06:27.949 INFO  - Language is forced to web
16:06:27.968 INFO  - Base dir: D:\Build\ParentProject\ProjectA
16:06:27.969 INFO  - Working dir: D:\Build\ParentProject\.sonar\ParentProject_ProjectA_ProjectA-webmodule
16:06:27.970 INFO  - Source paths: grails-app/views
16:06:27.970 INFO  - Source encoding: UTF-8, default locale: en_EN
16:06:27.971 INFO  - Index files
16:06:27.972 INFO  - Excluded sources:
16:06:27.973 INFO  -   web-app/js/jquery/**
16:06:28.027 INFO  - 28 files indexed
16:06:28.028 INFO  - 0 files ignored because of inclusion/exclusion patterns
16:06:28.273 INFO  - Quality profile for web: ParentProject
16:06:28.306 INFO  - Sensor Lines Sensor
16:06:28.312 INFO  - Sensor Lines Sensor (done) | time=6ms
16:06:28.312 INFO  - Sensor QProfileSensor
16:06:28.313 INFO  - Sensor QProfileSensor (done) | time=1ms
16:06:28.314 INFO  - Sensor InitialOpenIssuesSensor
16:06:28.409 INFO  - Sensor InitialOpenIssuesSensor (done) | time=95ms
16:06:28.410 INFO  - Sensor ProjectLinksSensor
16:06:28.413 INFO  - Sensor ProjectLinksSensor (done) | time=3ms
16:06:28.414 INFO  - Sensor VersionEventsSensor
16:06:28.424 INFO  - Sensor VersionEventsSensor (done) | time=10ms
16:06:28.424 INFO  - Sensor WebSensor
16:06:28.722 INFO  - Sensor WebSensor (done) | time=298ms
16:06:28.723 INFO  - Sensor SCM Sensor
16:06:28.738 INFO  - Sensor SCM Sensor (done) | time=15ms
16:06:28.739 INFO  - Sensor CPD Sensor
16:06:28.740 INFO  - DefaultCpdEngine is used for web
16:06:28.740 INFO  - Cross-project analysis enabled
16:06:29.201 INFO  - Sensor CPD Sensor (done) | time=462ms
16:06:29.203 INFO  - No quality gate is configured.
16:06:29.207 INFO  - Compare to previous analysis (2015-10-01)
16:06:29.209 INFO  - Compare over 30 days (2015-09-01, analysis of Mon Aug 31 01:18:52 CEST 2015)
16:06:29.211 INFO  - Compare over 21 days (2015-09-10, analysis of Wed Sep 09 01:18:12 CEST 2015)
16:06:29.522 INFO  - Execute decorators...
16:06:31.389 INFO  - -------------  Scan ProjectA
16:06:31.391 INFO  - Load module settings
16:06:31.440 INFO  - Base dir: D:\Build\ParentProject\ProjectA
16:06:31.441 INFO  - Working dir: D:\Build\ParentProject\.sonar\ParentProject_ProjectA
16:06:31.442 INFO  - Source encoding: UTF-8, default locale: en_EN
16:06:31.474 INFO  - Sensor Lines Sensor
16:06:31.474 INFO  - Sensor Lines Sensor (done) | time=0ms
16:06:31.475 INFO  - Sensor InitialOpenIssuesSensor
16:06:31.513 INFO  - Sensor InitialOpenIssuesSensor (done) | time=38ms
16:06:31.514 INFO  - Sensor ProjectLinksSensor
16:06:31.517 INFO  - Sensor ProjectLinksSensor (done) | time=3ms
16:06:31.518 INFO  - Sensor VersionEventsSensor
16:06:31.528 INFO  - Sensor VersionEventsSensor (done) | time=10ms
16:06:31.529 INFO  - Sensor SCM Sensor
16:06:31.530 INFO  - Sensor SCM Sensor (done) | time=1ms
16:06:31.530 INFO  - Sensor CPD Sensor
16:06:31.531 INFO  - Sensor CPD Sensor (done) | time=1ms
16:06:31.532 INFO  - No quality gate is configured.
16:06:31.537 INFO  - Compare to previous analysis (2015-10-01)
16:06:31.538 INFO  - Compare over 30 days (2015-09-01, analysis of Mon Aug 31 01:18:52 CEST 2015)
16:06:31.540 INFO  - Compare over 21 days (2015-09-10, analysis of Wed Sep 09 01:18:12 CEST 2015)
16:06:31.808 INFO  - Execute decorators...
16:06:31.932 INFO  - -------------  Scan ParentProject SonarQube Runner
16:06:31.934 INFO  - Load module settings
16:06:31.985 INFO  - Base dir: D:\Build\ParentProject
16:06:31.986 INFO  - Working dir: D:\Build\ParentProject\.sonar
16:06:31.986 INFO  - Source encoding: UTF-8, default locale: en_EN
16:06:32.020 INFO  - Sensor Lines Sensor
16:06:32.021 INFO  - Sensor Lines Sensor (done) | time=1ms
16:06:32.021 INFO  - Sensor InitialOpenIssuesSensor
16:06:32.062 INFO  - Sensor InitialOpenIssuesSensor (done) | time=41ms
16:06:32.063 INFO  - Sensor ProjectLinksSensor
16:06:32.067 INFO  - Sensor ProjectLinksSensor (done) | time=4ms
16:06:32.067 INFO  - Sensor VersionEventsSensor
16:06:32.077 INFO  - Sensor VersionEventsSensor (done) | time=10ms
16:06:32.078 INFO  - Sensor SCM Sensor
16:06:32.078 INFO  - Sensor SCM Sensor (done) | time=0ms
16:06:32.079 INFO  - Sensor CPD Sensor
16:06:32.079 INFO  - Sensor CPD Sensor (done) | time=0ms
16:06:32.081 INFO  - No quality gate is configured.
16:06:32.086 INFO  - Compare to previous analysis (2015-10-01)
16:06:32.088 INFO  - Compare over 30 days (2015-09-01, analysis of Mon Aug 31 01:18:52 CEST 2015)
16:06:32.090 INFO  - Compare over 21 days (2015-09-10, analysis of Wed Sep 09 01:18:12 CEST 2015)
16:06:32.280 INFO  - Execute decorators...
16:06:32.437 INFO  - Store results in database
16:06:34.455 INFO  - Analysis reports generated in 269ms, dir size=85 KB
16:06:34.762 INFO  - Analysis reports compressed in 305ms, zip size=57 KB
16:06:35.137 INFO  - Analysis reports sent to server in 374ms
16:06:35.138 INFO  - ANALYSIS SUCCESSFUL, you can browse http://server/dashboard/index/ParentProject
16:06:35.139 INFO  - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 56.500s
Final Memory: 73M/1274M
INFO: ------------------------------------------------------------------------

有人能在这方面提供任何帮助吗?

****update****:coverage.xml内容(截断):

<coverage line-rate="0.1625615763546798" branch-rate="0.034403669724770644" lines-covered="33" lines-valid="203" branches-covered="15" branches-valid="436" complexity="0.0" version="2.0.3" timestamp="1444086827204">
  <sources>
    <source>
      D:/Build/ParentProject/grails-app/services
    </source>
    <source>
      D:/Build/ParentProject/src/groovy
    </source>
    <source>
      D:/Build/ParentProject/grails-app/taglib
    </source>
    <source>
      D:/Build/ParentProject/grails-app/controllers
    </source>
  </sources>
  <packages>
    <package name="" line-rate="0.5" branch-rate="0.0" complexity="0.0">
      <classes>
        <class name="GrailsMelodyConfig" filename="GrailsMelodyConfig.groovy" line-rate="1.0" branch-rate="1.0" complexity="0.0">
          <methods>
            <method name="run" signature="()Ljava/lang/Object;" line-rate="1.0" branch-rate="1.0">
              <lines>
                <line number="24" hits="1" branch="false"/>
              </lines>
            </method>
          </methods>
          <lines>
            <line number="24" hits="1" branch="false"/>
          </lines>
        </class>
        <class name="HelpContextFilters" filename="HelpContextFilters.groovy" line-rate="1.0" branch-rate="1.0" complexity="0.0">
          <methods/>
          <lines/>
        </class>
        <class name="Filters" filename="Filters.groovy" line-rate="1.0" branch-rate="1.0" complexity="0.0">
          <methods/>
          <lines/>
        </class>
        <class name="Filters$_closure1" filename="Filters.groovy" line-rate="1.0" branch-rate="1.0" complexity="0.0">
          <methods>
            <method name="doCall" signature="(Ljava/lang/Object;)Ljava/lang/Object;" line-rate="1.0" branch-rate="1.0">
              <lines>
                <line number="5" hits="1" branch="false"/>
              </lines>
            </method>
          </methods>
          <lines>
            <line number="5" hits="1" branch="false"/>
          </lines>
        </class>
        <class name="Filters$_closure1$_closure2" filename="Filters.groovy" line-rate="1.0" branch-rate="1.0" complexity="0.0">
          <methods>
            <method name="doCall" signature="(Ljava/lang/Object;)Ljava/lang/Object;" line-rate="1.0" branch-rate="1.0">
              <lines>
                <line number="6" hits="1" branch="false"/>
              </lines>
            </method>
          </methods>
          <lines>
            <line number="6" hits="1" branch="false"/>
          </lines>
        </class>
        <class name="Filters$_closure1$_closure2$_closure3" filename="Filters.groovy" line-rate="0.0" branch-rate="0.0" complexity="0.0">
          <methods>
            <method name="doCall" signature="(Ljava/lang/Object;)Ljava/lang/Object;" line-rate="0.0" branch-rate="0.0">
              <lines>
                <line number="7" hits="0" branch="true" condition-coverage="0% (0/2)">
                  <conditions>
                    <condition number="0" type="jump" coverage="0%"/>
                  </conditions>
                </line>
                <line number="8" hits="0" branch="true" condition-coverage="0% (0/4)">
                  <conditions>
                    <condition number="0" type="jump" coverage="0%"/>
                    <condition number="1" type="jump" coverage="0%"/>
                  </conditions>
                </line>
                <line number="9" hits="0" branch="false"/>
              </lines>
            </method>
          </methods>
          <lines>
            <line number="7" hits="0" branch="true" condition-coverage="0% (0/2)">
              <conditions>
                <condition number="0" type="jump" coverage="0%"/>
              </conditions>
            </line>
            <line number="8" hits="0" branch="true" condition-coverage="0% (0/4)">
              <conditions>
                <condition number="0" type="jump" coverage="0%"/>
                <condition number="1" type="jump" coverage="0%"/>
              </conditions>
            </line>
            <line number="9" hits="0" branch="false"/>
          </lines>
        </class>
      </classes>
    </package>
    <package name="com" line-rate="0.0" branch-rate="0.0" complexity="0.0">
      <classes>
        <class name="com.CustomHtmlTagLib" filename="com/CustomHtmlTagLib.groovy" line-rate="1.0" branch-rate="1.0" complexity="0.0">
          <methods/>
          <lines/>
        </class>
        <class name="com.CustomHtmlTagLib$_closure1" filename="com/CustomHtmlTagLib.groovy" line-rate="0.0" branch-rate="0.0" complexity="0.0">
          <methods>
            <method name="doCall" signature="(Ljava/lang/Object;)Ljava/lang/Object;" line-rate="0.0" branch-rate="0.0">
              <lines>
                <line number="16" hits="0" branch="false"/>
                <line number="18" hits="0" branch="true" condition-coverage="0% (0/4)">
                  <conditions>
                    <condition number="0" type="jump" coverage="0%"/>
                    <condition number="1" type="jump" coverage="0%"/>
                  </conditions>
                </line>
                <line number="19" hits="0" branch="false"/>
                <line number="21" hits="0" branch="false"/>
              </lines>
            </method>
          </methods>
          <lines>
            <line number="16" hits="0" branch="false"/>
            <line number="18" hits="0" branch="true" condition-coverage="0% (0/4)">
              <conditions>
                <condition number="0" type="jump" coverage="0%"/>
                <condition number="1" type="jump" coverage="0%"/>
              </conditions>
            </line>
            <line number="19" hits="0" branch="false"/>
            <line number="21" hits="0" branch="false"/>
          </lines>
        </class>
        <class name="com.CustomHtmlTagLib$_closure2" filename="com/CustomHtmlTagLib.groovy" line-rate="0.0" branch-rate="1.0" complexity="0.0">
          <methods>
            <method name="doCall" signature="(Ljava/lang/Object;)Ljava/lang/Object;" line-rate="0.0" branch-rate="1.0">
              <lines>
                <line number="26" hits="0" branch="false"/>
              </lines>
            </method>
          </methods>
          <lines>
            <line number="26" hits="0" branch="false"/>
          </lines>
        </class>
      </classes>
    </package>
    ... TRUNCATED ...
  </packages>
</coverage>

共有1个答案

翟嘉年
2023-03-14

最后,对上述问题给出了答案。把它贴在这里,这样它就可以对别人有所帮助了。

在coverage.xml中,对于某些源文件,行号的计算结果为“0”,如下所示:

<line number="0" hits="0" branch="true" condition-coverage="33% (1/3)">
  <conditions>
    <condition number="0" type="switch" coverage="33%"/>
  </conditions>
</line>

有两种解决方案来处理相同的问题:

    null
  • http://dublintech.blogspot.nl/2015/06/problems-with-cobertura-and-sonar-51.html
  • http://sonarqube-archive.15.x6.nabble.com/arrayindexoutofboundsexception-with-sourcepersister-since-5-1-td5034233.html

尽管他们面临ArrayIndexOutOfBoundsException,我还是尝试了他们的解决方案,它对我也很有效。

更新:我还将Sonarqube Groovy插件从1.2恢复到1.0.1,它与上面的解决方案一起也有所帮助。上面的解决方案不适用于Sonarqube Groovy插件1.2。

更新2:我创建了一个小的groovy代码,它将在coverage.xml创建结束时运行,在运行sonar-runner之前运行。这段groovy代码遍历所有创建的coverage.xml并删除包含行号=“0”的节点。这样,文件也是覆盖的一部分,没有任何东西被排除在外。

 类似资料:
  • 我有一个使用maven(scala-maven-plugin)构建的scala项目(有几个java文件)。我们为代码覆盖率插入了jacoco(jacoco-maven-plugin),这会生成良好的scala代码覆盖率。我们可以在/target中的典型位置看到html/csv报告,scala覆盖范围很好。 但是,我们无法使用sonar来处理scala文件。插件运行并发送java报道,所以我知道它从

  • Overview Sonar -- an open platform to manage code quality. 是SCM, CI, Issue Tracker和Wiki外,另一个必不可少的项目管理软件. 什么maven site, 什么Jenkins插件,和它比都弱爆了。 Configuration 每次升级Sonar版本,总要做的几样配置,Sonar backup只能备份所有profile

  • Sonar(SonarQube)是一个开源平台,用于管理源代码的质量。Sonar 不只是一个质量数据报告工具,更是代码质量管理平台。支持的语言包括:Java、PHP、C#、C、Cobol、PL/SQL、Flex 等。 主要特点: 代码覆盖:通过单元测试,将会显示哪行代码被选中 改善编码规则 搜寻编码规则:按照名字,插件,激活级别和类别进行查询 项目搜寻:按照项目的名字进行查询 对比数据:比较同一张表中的任何测量的趋势 架构图:

  • 我试着运行mvn声纳:声纳,我得到了这个: [ERROR]无法在YamarinArtifactId项目上执行goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar(默认-CLI):Can not execute sonar:FxCop执行失败。FxCop执行失败,返回代码为“521”。有关更多信息,请查看FxCop文档。->[帮助1] 你知道该怎么办

  • Sonar 是由微软 Edge 浏览器团队开源的 linting 工具和网站扫描工具,能够帮助站长检查网站潜藏的性能和安全问题,帮助开发者创建更快、更好和更安全的网站。该工具既可以作为网页服务运行,也可以当做命令行工具来深度整合到开发者的工作流程和规则中。 Sonar 最早于2015年被微软提出,并命名为“ Sonar 计划 ”(Project Sonar),依靠虚拟机在恶意软件到达用户系统之前,

  • Sonar 是一个用于调试 iOS 和 Android 移动应用的平台,通过一个简单的界面,开发者可以可视化地审查和控制其 APP,除了可以直接使用,Sonar 还支持使用插件 API 进行扩展。 三年前 Facebook 已经开源过一款基于 Chrome 开发者工具的 Android 调试桥 Stetho,此次发布的 Sonar 比之更加先进,主要体现在跨平台、更丰富的用户体验,以及最主要的可扩