• <small id='Rk8px'></small><noframes id='Rk8px'>

      <legend id='Rk8px'><style id='Rk8px'><dir id='Rk8px'><q id='Rk8px'></q></dir></style></legend>
      <tfoot id='Rk8px'></tfoot>

      <i id='Rk8px'><tr id='Rk8px'><dt id='Rk8px'><q id='Rk8px'><span id='Rk8px'><b id='Rk8px'><form id='Rk8px'><ins id='Rk8px'></ins><ul id='Rk8px'></ul><sub id='Rk8px'></sub></form><legend id='Rk8px'></legend><bdo id='Rk8px'><pre id='Rk8px'><center id='Rk8px'></center></pre></bdo></b><th id='Rk8px'></th></span></q></dt></tr></i><div id='Rk8px'><tfoot id='Rk8px'></tfoot><dl id='Rk8px'><fieldset id='Rk8px'></fieldset></dl></div>

        • <bdo id='Rk8px'></bdo><ul id='Rk8px'></ul>

        如何让 Sonar 忽略 codeCoverage 指标的某些类?

        How to make Sonar ignore some classes for codeCoverage metric?(如何让 Sonar 忽略 codeCoverage 指标的某些类?)
        <i id='MWJnW'><tr id='MWJnW'><dt id='MWJnW'><q id='MWJnW'><span id='MWJnW'><b id='MWJnW'><form id='MWJnW'><ins id='MWJnW'></ins><ul id='MWJnW'></ul><sub id='MWJnW'></sub></form><legend id='MWJnW'></legend><bdo id='MWJnW'><pre id='MWJnW'><center id='MWJnW'></center></pre></bdo></b><th id='MWJnW'></th></span></q></dt></tr></i><div id='MWJnW'><tfoot id='MWJnW'></tfoot><dl id='MWJnW'><fieldset id='MWJnW'></fieldset></dl></div>
          <tbody id='MWJnW'></tbody>

        • <bdo id='MWJnW'></bdo><ul id='MWJnW'></ul>
          <legend id='MWJnW'><style id='MWJnW'><dir id='MWJnW'><q id='MWJnW'></q></dir></style></legend>

              • <small id='MWJnW'></small><noframes id='MWJnW'>

                  <tfoot id='MWJnW'></tfoot>

                  本文介绍了如何让 Sonar 忽略 codeCoverage 指标的某些类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 Maven 中有一个 Sonar 配置文件.除了代码覆盖率指标外,一切正常.我想让 Sonar 仅针对代码覆盖率指标忽略某些类.我有以下个人资料:

                  I have a Sonar profile in Maven. Everything works fine except the code coverage metric. I want to make Sonar ignore some classes only for the code coverage metric. I have the following profile:

                  <profile>
                      <id>sonar</id>
                      <properties>
                          <sonar.exclusions>**/beans/jaxb/**</sonar.exclusions>
                      </properties>
                      <build>
                          <plugins>
                              <plugin>
                                  <groupId>org.apache.maven.plugins</groupId>
                                  <artifactId>maven-surefire-plugin</artifactId>
                                  <version>${maven.surefire.plugin.version}</version>
                                  <configuration>
                                      <redirectTestOutputToFile>true</redirectTestOutputToFile>
                                      <excludes>
                                          <exclude>**/*Suite*.java</exclude>
                                          <exclude>**/*RemoteTest.java</exclude>
                                          <exclude>**/*SpringTest.java</exclude>
                                          <exclude>**/*CamelTest.java</exclude>
                                          <exclude>**/*FunctionalTest.java</exclude>
                                          <exclude>**/*IntegrationTest.java</exclude>
                                          <exclude>**/*DaoBeanTest.java</exclude>
                                      </excludes>
                                  </configuration>
                              </plugin>                    
                          </plugins>
                      </build>
                  </profile>
                  

                  请帮忙.我尝试添加类似

                  Please help. I tried to add something like

                  <exclude>com/qwerty/dw/publisher/Main.class</exclude>
                  

                  但没用

                  更新

                  我有正确的 Cobertura 个人资料.我尝试将其添加到 Sonar 配置文件中,但我仍然有 53% 而不是像 Cobertura 配置文件中那样的大约 95%

                  I have a correct Cobertura profile. I tried to add it to the Sonar profile, but still I have 53% instead about 95% like in the Cobertura profile

                  <profile>
                      <id>sonar</id>
                      <properties>
                          <sonar.exclusions>**/beans/jaxb/**</sonar.exclusions>
                          <sonar.core.codeCoveragePlugin>cobertura</sonar.core.codeCoveragePlugin>
                      </properties>
                      <build>
                          <plugins>
                              <plugin>
                                  <groupId>org.apache.maven.plugins</groupId>
                                  <artifactId>maven-surefire-plugin</artifactId>
                                  <version>${maven.surefire.plugin.version}</version>
                                  <configuration>
                                      <redirectTestOutputToFile>true</redirectTestOutputToFile>
                                      <excludes>
                                          <exclude>**/*Suite*.java</exclude>
                                          <exclude>**/*RemoteTest.java</exclude>
                                          <exclude>**/*SpringTest.java</exclude>
                                          <exclude>**/*CamelTest.java</exclude>
                                          <exclude>**/*FunctionalTest.java</exclude>
                                          <exclude>**/*IntegrationTest.java</exclude>
                                          <exclude>**/*DaoBeanTest.java</exclude>
                                      </excludes>
                                  </configuration>
                              </plugin>
                              <plugin>
                                  <groupId>org.codehaus.mojo</groupId>
                                  <artifactId>cobertura-maven-plugin</artifactId>
                                  <version>${cobertura.maven.plugin.version}</version>
                                  <configuration>
                                      <instrumentation>
                                          <excludes>
                                              <exclude>com/qwerty/dw/dao/*</exclude>
                                              <exclude>com/qwerty/dw/domain/*</exclude>
                                              <exclude>com/qwerty/dw/beans/**/*</exclude>
                                              <exclude>com/qwerty/dw/daemon/exception/*</exclude>
                                              <exclude>com/qwerty/dw/daemon/Main.class</exclude>
                                              <exclude>com/qwerty/dw/sink/Main.class</exclude>
                                              <exclude>com/qwerty/dw/publisher/Main.class</exclude>
                                              <exclude>com/qwerty/dw/publisher/dao/*</exclude>
                                              <exclude>com/qwerty/dw/publisher/domain/*</exclude>
                                          </excludes>
                                      </instrumentation>
                                      <formats>
                                          <format>html</format>
                                      </formats>
                                      <aggregate>true</aggregate>
                                      <check>
                                          <haltOnFailure>true</haltOnFailure>
                                          <branchRate>60</branchRate>
                                          <lineRate>60</lineRate>
                                          <totalBranchRate>60</totalBranchRate>
                                          <totalLineRate>60</totalLineRate>
                                      </check>
                                  </configuration>
                                  <executions>
                                      <execution>
                                          <goals>
                                              <goal>clean</goal>
                                              <goal>check</goal>
                                          </goals>
                                      </execution>
                                  </executions>
                              </plugin>
                          </plugins>
                      </build>
                  </profile>
                  

                  推荐答案

                  在撰写本文时(使用 SonarQube 4.5.1),要设置的正确属性是 sonar.coverage.exclusions,例如:

                  At the time of this writing (which is with SonarQube 4.5.1), the correct property to set is sonar.coverage.exclusions, e.g.:

                  <properties>
                      <sonar.coverage.exclusions>foo/**/*,**/bar/*</sonar.coverage.exclusions>
                  </properties>
                  

                  这似乎与之前的几个版本有所不同.请注意,这仅将给定类从覆盖率计算中排除.计算所有其他指标和问题.

                  This seems to be a change from just a few versions earlier. Note that this excludes the given classes from coverage calculation only. All other metrics and issues are calculated.

                  为了找到您的 SonarQube 版本的属性名称,您可以尝试转到 SonarQube 实例的 General Settings 部分并查找 Code Coverage 项(在 SonarQube 4.5.x 中,常规设置 → 排除 → 代码覆盖率).在输入字段下方,它给出了上面提到的属性名称(Key: sonar.coverage.exclusions").

                  In order to find the property name for your version of SonarQube, you can try going to the General Settings section of your SonarQube instance and look for the Code Coverage item (in SonarQube 4.5.x, that's General Settings → Exclusions → Code Coverage). Below the input field, it gives the property name mentioned above ("Key: sonar.coverage.exclusions").

                  这篇关于如何让 Sonar 忽略 codeCoverage 指标的某些类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Slf4j LoggerFactory.getLogger and sonarqube(Slf4j LoggerFactory.getLogger 和 sonarqube)
                  Security - Array is stored directly(安全性 - 数组直接存储)
                  SonarQube quot;Class Not Foundquot; during Main AST Scan(SonarQube“找不到类在主 AST 扫描期间)
                  Integrate Spock#39;s test with Sonar(将 Spock 的测试与声纳集成)
                  How do I make Hudson/Jenkins fail if Sonar thresholds are breached?(如果违反声纳阈值,我如何让 Hudson/Jenkins 失败?)
                  automatically add curly brackets to all if/else/for/while etc. in a java code-base(自动将大括号添加到 java 代码库中的所有 if/else/for/while 等)

                          <tbody id='wFDsd'></tbody>
                      1. <legend id='wFDsd'><style id='wFDsd'><dir id='wFDsd'><q id='wFDsd'></q></dir></style></legend>

                        • <bdo id='wFDsd'></bdo><ul id='wFDsd'></ul>

                          <small id='wFDsd'></small><noframes id='wFDsd'>

                          <tfoot id='wFDsd'></tfoot>

                            <i id='wFDsd'><tr id='wFDsd'><dt id='wFDsd'><q id='wFDsd'><span id='wFDsd'><b id='wFDsd'><form id='wFDsd'><ins id='wFDsd'></ins><ul id='wFDsd'></ul><sub id='wFDsd'></sub></form><legend id='wFDsd'></legend><bdo id='wFDsd'><pre id='wFDsd'><center id='wFDsd'></center></pre></bdo></b><th id='wFDsd'></th></span></q></dt></tr></i><div id='wFDsd'><tfoot id='wFDsd'></tfoot><dl id='wFDsd'><fieldset id='wFDsd'></fieldset></dl></div>