【问题标题】:Maven sonar plugin configurations for findbugs pmd checkstyle coberturafindbugs pmd checkstyle cobertura 的 Maven 声纳插件配置
【发布时间】:2012-08-08 06:48:08
【问题描述】:

我需要一些帮助来设置 maven 项目的代码质量插件。
我有一个多模块项目。虽然我在构建过程中配置了 pmdcheckstylefindbugscobertura,并且可以为每个插件生成 xml 报告,但我在项目中配置声纳插件时面临一些挑战。

我不知道如何解决这个问题:

  1. 我应该在执行声纳时重复使用这些插件生成的报告吗?如果是这样,我的声纳插件配置应该是什么?
  2. 如果我使用嵌入的pmdcheckstylefindbugscobertura 插件运行声纳,如何将它们配置为仅针对特定包运行或使findbugs 分析com.mycompany.- 结构。
  3. 最后,我无法在声纳中获得覆盖报告,无论是在声纳外部还是在声纳内运行 cobertura。

我在下面有我的 pom 供审核。任何帮助将不胜感激。

这是在我的根 pom 中构建部分的插件部分:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <instrumentation>
                    <includes>
                        <include>com/mycompany/**/*.class</include>
                    </includes>                 
                </instrumentation>
                <formats>
                    <format>xml</format>
                </formats>
            </configuration>                
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-pmd-plugin</artifactId>
            <version>2.7.1</version>
            <configuration>
                <sourceEncoding>utf-8</sourceEncoding>
                <minimumTokens>100</minimumTokens>
                <targetJdk>1.6</targetJdk>
                <includes>
                    <include>com/mycompany/**/*.java</include>                      
                </includes>
                <excludeRoots>
                    <excludeRoot>target/generated-sources/*</excludeRoot>
                </excludeRoots>
            </configuration>
        </plugin>   
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>2.5.2</version>
            <configuration>
                <onlyAnalyze>com.mycompany.-</onlyAnalyze>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.9.1</version>
            <configuration>
                <includes>com/mycompany/**/*.java</includes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>2.0</version>
        </plugin>

【问题讨论】:

    标签: maven sonarqube findbugs checkstyle cobertura


    【解决方案1】:

    1) 我应该重复使用这些插件生成的报告吗? 执行声纳?如果是这样,我的声纳插件配置应该是什么?

    Sonar 不提供机制来重用这些插件生成的报告。您可以通过quality profiles配置规则。

    2) 如果我使用嵌入式 pmd、checkstyle、findbugs 和 cobertura 插件运行声纳,我如何将它们配置为仅针对特定包运行或让 findbugs 分析“com.mycompany.-”结构。

    Sonar Web UI 允许您为 findbugs 过滤器指定排除项。对于 cobertura 也是如此。不确定 pmd,checkstyle。

    3) 最后,我无法在声纳中获得覆盖报告,无论是在声纳外部还是在声纳内运行 cobertura。

    这可能是由于jacoco being the default code coverage engine。您可以按照说明运行mvn clean verify/install sonar:sonar,看看它是否有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-29
      • 2015-03-22
      • 1970-01-01
      • 1970-01-01
      • 2017-07-30
      • 1970-01-01
      • 2014-01-19
      相关资源
      最近更新 更多