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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
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