无法找到不同版本的Sonar Qube之间的差异

时间:2019-11-21 10:58:43

标签: java plugins sonarqube code-analysis

通过遵循本文档,我为SonarQube开发了一个自定义插件,其中包含大约20个Java自定义规则。 https://docs.sonarqube.org/display/PLUG/Writing+Custom+Java+Rules+101

我的所有规则在SonarQube-6.2中都运行良好,但是只有一个规则在7.6中运行,而SonarQube-7.7甚至还没有开始。

使用更高版本时是否缺少任何内容?

下面是我制定的一些规则:

  1. 埃及牙套
  2. 总是制表符,绝不能空格
  3. 更正制表符缩进
  4. 缩进连续行至少2个制表符
  5. 导入后
  6. 1或2个空白行
  7. 方法末尾没有空白行

下面是我的pom.xml:

http://maven.apache.org/maven-v4_0_0.xsd“>     4.0.0

<groupId>com.aaaa.bbbb</groupId>
<artifactId>sonar-custom-rules-java</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>sonar-plugin</packaging>

<name>SonarQube Java Custom Rules</name>
<description>Plugin with custom SonarQube Rules for Java used.</description>

<properties>
    <sslr.version>1.21</sslr.version>
    <gson.version>2.6.2</gson.version>

    <sonar.version>6.0</sonar.version>
    <sonarjava.version>4.5.0.8398</sonarjava.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.sonarsource.sonarqube</groupId>
        <artifactId>sonar-plugin-api</artifactId>
        <version>${sonar.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.sonarsource.java</groupId>
        <artifactId>sonar-java-plugin</artifactId>
        <type>sonar-plugin</type>
        <version>${sonarjava.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.sonarsource.sslr-squid-bridge</groupId>
        <artifactId>sslr-squid-bridge</artifactId>
        <version>2.6.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.codehaus.sonar.sslr</groupId>
                <artifactId>sslr-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.codehaus.sonar</groupId>
                <artifactId>sonar-plugin-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.codehaus.sonar.sslr</groupId>
                <artifactId>sslr-xpath</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl-over-slf4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.sonarsource.java</groupId>
        <artifactId>java-checks-testkit</artifactId>
        <version>${sonarjava.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>${gson.version}</version>
    </dependency>

    <dependency>
        <groupId>org.sonarsource.sslr</groupId>
        <artifactId>sslr-testing-harness</artifactId>
        <version>${sslr.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>19.0</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.2</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>3.6.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>0.9.30</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
            <artifactId>sonar-packaging-maven-plugin</artifactId>
            <version>1.17</version>
            <extensions>true</extensions>
            <configuration>
                <pluginKey>java-custom</pluginKey>
                <pluginName>Java Custom Rules</pluginName>
                <pluginClass>com.sonar.java.JavaRulesPlugin</pluginClass>
                <sonarLintSupported>true</sonarLintSupported>
                <sonarQubeMinVersion>5.6</sonarQubeMinVersion>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <!-- only required to run UT - these are UT dependencies -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.10</version>
            <executions>
                <execution>
                    <id>copy</id>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.apache.commons</groupId>
                                <artifactId>commons-collections4</artifactId>
                                <version>4.0</version>
                                <type>jar</type>
                            </artifactItem>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-api</artifactId>
                                <version>6.0</version>
                            </artifactItem>
                            <artifactItem>
                                <groupId>org.springframework</groupId>
                                <artifactId>spring-webmvc</artifactId>
                                <version>4.3.3.RELEASE</version>
                            </artifactItem>
                            <artifactItem>
                                <groupId>org.springframework</groupId>
                                <artifactId>spring-webmvc</artifactId>
                                <version>4.3.3.RELEASE</version>
                            </artifactItem>
                            <artifactItem>
                                <groupId>org.springframework</groupId>
                                <artifactId>spring-web</artifactId>
                                <version>4.3.3.RELEASE</version>
                            </artifactItem>
                            <artifactItem>
                                <groupId>org.springframework</groupId>
                                <artifactId>spring-context</artifactId>
                                <version>4.3.3.RELEASE</version>
                            </artifactItem>
                        </artifactItems>
                        <outputDirectory>${project.build.directory}/test-jars</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

1 个答案:

答案 0 :(得分:1)

您应该将您的配置与示例中的配置进行比较,自从您复制示例源代码以支持SonarQube的新版本以来,示例源代码已经得到了发展:

https://github.com/SonarSource/sonar-custom-rules-examples/blob/master/java-custom-rules/pom.xml

尤其是那些版本:

<sonar.version>7.7</sonar.version>
<sonarjava.version>5.12.1.17771</sonarjava.version>

如果您仍然无法使用新版本的插件和SonarQube遇到任何问题,请查看SonarQube logs/sonar.loglogs/web.log