Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current ·  View Page History

 

Manage existing violations

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

Fix a violation

Go through the Violations view that displays the list of violations of the selected resource (project, file, etc.):

A double-click on a violation opens the source code editor and highlights the violation:

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:

Create a review

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.

Work through reviews

It is possible to The reviews can be browsed through the Task List view:


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


All operations on reviews available through the Sonar web interface are also available in Mylyn, so a review can be commented, fixed, reassigned, flagged as false-positive and reopened. Moreover a review can be created directly from the Eclipse source code editor on an existing violation.

 

Known limitations

This Mylyn extension has currently the following limitations that should be quickly fixed:

  • 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

Check that you are not adding any technical debt in your code (Local)

Know limitation on differential services

This use case is not fully achievable as Sonar Eclipse does not support differential services yet.

Thus, you do not have yet any way to display violations you just added after running a local analysis.

Run 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 launched to update the Violations and Measures views.

Later, at any time, you can run a new local analysis by choosing Sonar => Run Local Analysis

Be Careful

Even in local mode, the Hotspots and Web views still display remote data.

Labels
  • None