Currently Being Moderated
Tobias Hofmann

Integrating Sonar with Eclipse

Posted by Tobias Hofmann in Java Development on Apr 20, 2012 4:41:20 PM

Sonar comes with a killer feature: Eclipse integration. This does not only mean that there is an Eclipse perspective available, but Sonar findings can be used with Mylyn.

 

Sonar perspective

To make use of the Sonar perspective, the Java project needs to be linked to the Sonar project.

sonar2_1.jpg

Associate project with Sonar project

sonar2_2.jpg

Select Sonar project

 

Now the Eclipse Sonar plugin is reading the identified issues from the Sonar server and integrates them in the editor view. Clicking on the item in the right opens – like any other Eclipse message – a window and shows possible solutions.

sonar2_3.jpg

The developer can now act on the violations inside Eclipse without needing to logon to the Sonar server and find there the violations for the source code he is working on.

 

Mylyn integration

Assume that besides the actual developers you have a code quality or coordination group that analyzes code and uses Sonar for doing so. Now Sonar shows all these violations, errors, bugs and so on, but how to communicate to the developer that he has to act on the violation? Or to guide him with documentation or how to find out why the code is written like it is? Mylyn can be used to enable that kind of collaboration. The Sonar web interface allows creating for every violation to add a comment and assign the violation to a specific user.

sonar2_4.jpg

Sonar web interface

 

This review was created with the id #30 assigned to it. After configuring Mylyn to work in Eclipse together with Sonar, the review shows up under this id in the task list:

sonar2_5.jpg

Opening the task reveals the tasks information:

sonar2_6.jpg

Without leaving Eclipse the developer can act on the violations assigned to him. A special feature is the ability to click on the resource link in the tasks and Eclipse will open the corresponding file automatically. The developer can mark the task as solved from within Eclipse and the task will get updated. This change is visible immediately and does not require a new code analysis by Sonar.

sonar2_8.jpg

Using Eclipse brings a major benefit: plugins and an eco-system. Unfortunately, SAP decides to not make their Eclipse plugins easily accessible via the update functionality, but other software vendors are not as restrictive, transforming Eclipse into a productivity tool for Java developers, making it possible to integrate it into a Java developer landscape. One can only hope that ABAP for Eclipse won’t get a second NWDS.

Comments

Actions

Filter Blog

By author:
By date:
By tag: