繁体   English   中英

针对findbugs pmd checkstyle cobertura的Maven声纳插件配置

[英]Maven sonar plugin configurations for findbugs pmd checkstyle cobertura

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

我不知道如何处理这个问题:

  1. 在执行声纳时,我应该重用这些插件生成的报告吗? 如果是这样我的声纳插件配置应该是什么?
  2. 如果我使用嵌入式pmdcheckstylefindbugscobertura插件运行声纳,我如何将它们配置为仅针对特定包运行或在com.mycompany.-结构上进行findbugs分析。
  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>

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

Sonar没有提供机制来重用这些插件生成的报告。 您可以通过质量配置文件配置规则。

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

Sonar Web UI允许您为findbugs过滤器指定排除项。 同样对于cobertura。 关于pmd,checkstyle不确定。

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

由于jacoco是默认的代码覆盖引擎,因此可能是可能的。 您可以按照指示运行mvn clean verify/install sonar:sonar ,看看它是否有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM