How to Setup Eclipse IDE for Sonar Analysis

This article describes steps required to configure your eclipse for SonarQube such that developers are not required to leave the eclipse IDE to manage their source code quality. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos.
Following are the key points described later in this article:

  • Installing & Configuraing SonarQube in Eclipse
  • Analyzing code using SonarQube

Installing & Configuring SonarQube in Eclipse

Follow the steps given on following pages to install and configure SonarQube in your Eclipse IDE.

  • The page on Installing SonarQube in Eclipse consists of steps required to install SonarQube in the IDE. Once downloaded, it would prompt to restart the Eclipse IDE. For proceeding ahead, you must restart the Eclipse IDE.
  • The page on Configuring SonarQube in Eclipseconsists of steps required to configure Eclipse for SonarQube. The key thing to note is the fact that as you click on Preferences > SonarQube > Servers, you see the default server entry for http://localhost:9000. Initially, as per instruction page, seeing the default entry, I went ahead to next step for linking the project to SonarQube server and run the analysis. However, it throw the error such as Unknowb version of SonarQube server. After a little research, I figured out that the error was thrown as the SonarQube Server was not reachable although I saw it configured as http://localhost:9000. The solution is to go to Preferences > SonarQube > Servers, click “Edit” button and you would see SonarQube Server URL, username and password. The key is to give username and password and run the analysis once again.


Analyzing code using SonarQube

Once you are done with installation and configuration of SonarQUbe server in Eclipse IDE, for code analysis, all you need is right click on your project and click SonarQube > Analyze and that is it. The violations would appear in SonarQube analysis as shown in the screenshot below.

sonarqube analysis in eclipse

sonarqube analysis in eclipse

However, do note that these issues may not appear if you try to access on the browser. For that to happen, you need to once again run “sonar-runner” from the project root.

Ajitesh Kumar
Follow me

Leave A Reply

Time limit is exhausted. Please reload the CAPTCHA.