无法找到不同版本的 Sonarqube 之间的差异
Posted
技术标签:
【中文标题】无法找到不同版本的 Sonarqube 之间的差异【英文标题】:Unable to find differences between various versions of Sonar Qube 【发布时间】:2020-03-17 06:59:05 【问题描述】:按照本文档,我为 SonarQube 开发了一个自定义插件,其中包含大约 20 个 Java 自定义规则。 https://docs.sonarqube.org/display/PLUG/Writing+Custom+Java+Rules+101
我的所有规则在 SonarQube-6.2 中运行良好,但只有一个规则在 7.6 中运行,而 SonarQube - 7.7 甚至还没有启动。
在使用更高版本时我有什么遗漏吗?
以下是我制定的一些规则:
-
埃及牙套
总是制表符,从不空格
正确的制表符缩进
缩进续行至少 2 个制表符
导入后 1 或两个空行
方法末尾没有空行
下面是我的 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>
【问题讨论】:
如果您在问题中没有提供任何内容,很难知道您可能会错过什么。请提供您的规则和声纳配置的详细信息。 用我的一些规则和 pom.xml 文件编辑了我的查询。 SonarQube 日志文件中有内容吗? 【参考方案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.log
和 logs/web.log
。
【讨论】:
以上是关于无法找到不同版本的 Sonarqube 之间的差异的主要内容,如果未能解决你的问题,请参考以下文章