Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
iconfalse
titleTable of Contents

Table of Contents
maxLevel1

...

Info

This page documents how to work with SonarQube in Eclipse for versions 3.2+.

For versions prior to 3.2, browse this page.

Managing Existing Issues

When going through the source code, Sonar in SonarQubein Eclipse will highlight the existing violationsissues. The idea is that once you have read the code and understood it, the cost of fixing a violation an issue is low.

Fixing

...

an Issue

Browse the Sonar Issues view that displays the list of violations issues of the selected resource (project, file, etc.):Image Removed

Image Added

A double-click on a violation an issue icon opens the source code editor and highlights the violationissue:

Image Removed

Once a violation has been fixed, you can simply delete it by clicking on the violation icon and then by selecting the Delete violation item. Deleting a violation also removes it from the Violations view:

Image Removed

Creating a Review (Remote)

If, for any reason you are not going to fix a violation right away but you think it should be resolved, you can create a review on it.

Image Removed

Image Removed

Working through Reviews

It is possible to create custom queries to display reviews in the Task List view:

Image Removed
From there, double-clicking on a review open the detail of that review:
Image Removed

...

 

Note
titleKnown limitations

This Mylyn extension has currently the following limitations:

  • There is no way to create a review that doesn't relate to an existing violation
  • There is no way to create a Mylyn query with filters in order for instance to retrieve reviews only on a project, or reviews assigned to another user
  • There is no way to add a review to an action plan: SONARIDE-286

Checking Code Prior to Commit

When adding or changing the code of an application, Sonar in Eclipse provide Image Added

Reviewing an Issue (Remote)

Just like it's possible to review an issue through the web interface, you can review an issue directly in Eclipse:

Image Added

Image Added

Checking Code Prior to Commit

SonarQubein Eclipse provides the ability to show the quality of this changed/modified code prior to committing back pushing it to the SCM.

Note
titleKnow limitation on differential services

This use case is currently not fully supported since Sonar Eclipse does not provide a differential mode yet. It is therefore not possible to differentiate what defect was there before from what has been added by the changes.

Running Local Analysis (Local)

By default Sonar Eclipse takes care to automatically collect information from the Sonar Web server and decorates the source code on-the-fly (remote mode). This default mode is pretty useful as it does not consume any CPU or memory on the developer's computer while quickly displaying valuable quality information as soon as a new source file is opened.

But if lots of source code has been modified locally, quality information available remotely might be quite desynchronized after a while. In that case, a local analysis can be run before committing any changes to the source code repository and with the same quality profile used to analyze the project remotely.

To run a local analysis, switch to the local mode. As soon as this mode is selected a local analysis is run to update the Violations view.
Image Removed
Later, at any time, you can run a new local analysis by clicking on Sonar > Run Local Analysis

 

After running a local analysis, if new issues have been introduced (comparison made against the latest analysis on the SonarQube server), Eclipse will clearly highlight them: the icon is red and the line is highlighted. Moreover, every new issue is by default marked as an Error, meaning that it will also show up in the Eclipse Problems view, and the Package/Resource explorer will clearly show that your project has problems:

Image Added