Integrating Sonar with Eclipse
Note: 1st published at SCN on 20.4.2012
Note 2: this plugin is not anymore valid. The blog is from 2012!
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.
To make use of the Sonar perspective, the Java project needs to be linked to the Sonar project.
Associate project with Sonar project
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.
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.
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.
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:
Opening the task reveals the tasks information:
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.
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.