SonarQube analysis of guava v18 - InternalPrefixUnaryExpression cannot be cast to MethodInvocationTree - maven

Using SonarQube 6.3.1 server, org.sonarsource.scanner.maven:sonar-maven-plugin:3.2 and 3.3.0.603, Apache Maven 3.5.0, Java version: 1.8.0_91, vendor: Oracle Corporation, running Fedora 25
Steps to reproduce:
git clone --branch v18.0 https://github.com/google/guava.git
cd guava
mvn -X org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar
Posting this error here as I'm not allowed to create issue sonarsource jira
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project guava-parent: SonarQube is unable to analyze file : '/home/rsvoboda/tmp/guava/guava/src/com/google/common/util/concurrent/Monitor.java': org.sonar.java.model.expression.InternalPrefixUnaryExpression cannot be cast to org.sonar.plugins.java.api.tree.MethodInvocationTree -> [Help 1]
To me this is bug, I could get further using workaround: -Dsonar.exclusions=**/com/google/common/util/concurrent/Monitor.java

As far as I can tell you are hitting this problem : https://jira.sonarsource.com/browse/SONARJAVA-2140 Which has been fixed in version 4.6 of SonarJava analyzer. (bundled version with SonarQube 6.3.1 is 4.5, consider upgrading it to latest version 4.9 at time of writing).

I can confirm that update of SonarJava analyzer via updatecenter to the latest version (4.9) available helps. Thank you #benzonico for help.

Related

Maven 3.5.4 support

[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.6.1.Final:dev
(default-cli) on project thm:
Detected Maven Version (3.5.4) is not supported, it must be in [3.6.2,). ->
How come Maven support for Version 3.5.4 was dropped?
Everything is explained in details in the commit: https://github.com/quarkusio/quarkus/commit/7364c5b8efaee2253d54a4fe0a712c095c9defb6 .
We were affected by a resolver bug for some of our dependencies and using a more recent Maven was the way to fix it, thus why we enforce it.

SonarQube upgrade to 6.7.1 version : Old plugin Supported while upgrade

We are upgrading the Sonarqube from 5.6.3 to 6.7, our current Sonarqube has old plugin that we are using check the list below.
SonarJava sonar-java-plugin-4.6.0.8784
SOnarC# sonar-csharp-plugin-5.10.1.1411
SonarJS sonar-javascript-plugin-2.21.0.4409
SonarPlSql sonar-plsql-plugin-2.9.0.901
Ldap sonar-ldap-plugin-2.0
SonarPHP sonar-php-plugin-2.10.0.2087
PMD sonar-pmd-plugin-2.6
SonarQube :: Plugins :: SCM :: Git sonar-scm-git-plugin-1.2
SonarQube :: Plugins :: SCM :: SVN sonar-scm-svn-plugin-1.3
Sonar XML sonar-xml-plugin-1.4.2.885
When we try to setup SonarQube 6.7 all the above plugin works fine.
So My question is while upgrading from 5.6.3 to 6.7.1 Could we face any issues because of the Plugin.
Thanks in Advance!
Version 6.7.1 is a minor release and its plugin API has exactly the same behavior as 6.7. For this reason you can safely upgrade to 6.7.1 without changing plugins.
Note that, as a rule of thumb, exceptional breaking changes are listed in upgrade notes.

SonarQube 5.6 with Java Project (JDK 1.6)

I want to configure SonarQube for my maven project which is on jdk 1.6.
Can I use the latest SonarQube 5.6. It say code should be complied with jdk 1.8 only.
Is it possible to analyse code with older version of JDK with SonarQube on latest vesrion of JDK?
My project is compiled on jdk1.6. Do I need to use scanner which supports jdk1.6 because if I uses sonar-maven-plugin - 3.1.1 it gives error :
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1:sonar (default-cli) on project StreamDiffCLI: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1:sonar failed: Unable to load the mojo 'sonar' in the plugin 'org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 52.0
I believe you're misreading the docs. You can compile your project with whatever version of Java you like. 1.4 even. But you must analyze with 8.
If you are installing Sonar-Cube with latest version with JDK 1.8 but your project is compatible to JDK 1.6 the use :
if project are supporting JDK 1.6, please use “sonar.java.source=1.6” in your configuration file to avoid rules applicable for JDK>1.6
e.g in build.xml (ANT)

sonar-maven-plugin 5.1.1 not found

I've just installed the latest version of SonarQube (5.1.1) and when I try to run the sonar:sonar target, I get an error:
Embedded error: Unable to build project for plugin 'org.codehaus.sonar:sonar-maven-plugin': POM 'org.codehaus.sonar:sonar-maven-plugin' not found in repository: Unable to download the artifact from any repository
org.codehaus.sonar:sonar-maven-plugin:pom:5.1.1
I've checked here:
http://mvnrepository.com/artifact/org.codehaus.sonar/sonar-maven-plugin
And it seems that version 5.1.1 of the sonar-maven-plugin has not been pushed to the public repo(s).
Is that so or am I looking in the wrong location?
The sonar-maven-plugin is an independent project that does not follow SonarQube versioning.
Correct command-line is mvn org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
The groupId mvn.codehaus.sonar is for internal use.

Integrating sonarqube with Jenkins

I am trying to run sonar sonar:sonar by integrating sonarqube and jenkins. While doing, am getting the below error.
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project iwm_common: Can not execute SonarQube analysis: org.slf4j.impl.SimpleLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext -> [Help 1]
Jenkins version - 1.612
Sonarqube version - 3.6
JDK-1.7.0_76
Maven - 3.1.1
Jenkins WAR is deployed in server A and sonarqube is deployed in server B. I have not installed sonar-jenkins plugin in Jenkins.
Can anyone let me know whether sonar-jenkins plugin is mandatory to be installed in jenkins to integrate jenkins with any sonar server (eg:sonarqube).
If the answer is YES, then after installation of the required plugin, will adding the sonar server (eg:sonarqube) information under Manage Jenkins -> Configure system -> sonar resolve the above error ?
The error is related to sonar-maven-plugin and this plugin is not used in any of the project's pom.xml. Can anyone please explain whether this plugin gets referred as a part of sonar:sonar goal. Thanks.
The versions you specified are not compatible for running sonar analysis.
Please upgrade SonarQube version (current is 5.1.1) which requires
Java 1.7-1.8
SonarQube 5.0 or 5.1.1
Sonar-runner 2.4
Using latest version of sonarqube resolved the issue mentioned.

Resources