SonarQube Java version used to verify code

2020-03-20 09:25发布

How can I know against which version of Java SonarQube validates the code? Is it the version of the JVM? What then if my project is based on a different version?

2条回答
家丑人穷心不美
2楼-- · 2020-03-20 10:06

I do confirm that this property sonar.java.source is used only by the PMD tool. The SonarSource's Java analyser uses a superset grammar and so can analyse source files regardless of the Java version they comply to.

查看更多
SAY GOODBYE
3楼-- · 2020-03-20 10:21

The default value is 1.5.

To set the appropriate version, you need to set sonar.java.source property to tell PMD which version of Java your source code complies to.

Possible values: 1.4, 1.5 or 5, 1.6 or 6, 1.7 or 7. Since version 2.2 of the plugin, this property can also be set to 1.8 or 8.

If you're using the ant task, just add:

 <property name="sonar.java.source" value="${javaversion}"/> 

If you're using the SonarRunner, just add the line below to the file <install_directory>/conf/sonar-runner.properties:

sonar.java.source=1.5
查看更多
登录 后发表回答