Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Setup Eclipse IDE for Sonar Analysis

DZone's Guide to

How to Setup Eclipse IDE for Sonar Analysis

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

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 & Configuraing 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.

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.

Topics:
java ,sonar ,eclipse ,ide ,sonarqube

Published at DZone with permission of Ajitesh Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}