| Info | ||||
|---|---|---|---|---|
| ||||
|
Local and Remote Mode
When using Sonar in Eclipse, 2 two modes are available:
Remote Mode
This is the default mode. Information showed in the remote mode is coming from a remote Sonar server. This means that those this information have has been computed during the latest analysis on that server.
Thus:
...
, you will not see violations introduced in the code that you just added or changed.
...
Local Mode
When switching to the local mode, information displayed is coming from the latest local analysis.
Thus:
...
, you can see the violations introduced in the code that you just added or changed.
...
Switch from One Mode to Another
To switch from one mode to another, right-click on the project, then select Sonar > Mode > Remote or Local:

Features below will be tagged as Remote or/and Local depending on their availability.
The Sonar Eclipse Perspective
Sonar Eclipse provides one Eclipse perspective and four Eclipse views. Those Eclipse views can of course be used outside the Sonar Eclipse perspective, but this tutorial describes the default Sonar Eclipse perspective layout.
To activate the Sonar Eclipse perspective, click on Windows => Open Perspective => Other... and select Sonar:

The Measures View (Remote and Local)
The Measures view allows to gather all available measures on the selected ressource. Most of the time, developers focus their attention on only a few metrics like complexity, uncovered lines of code by unit tests, duplicated lines, etc. and want to get a quick overview on those metrics. That's why favourite metrics are displayed on the top of the Measures view. Adding or removing a metric from the Favourites list is possible by right clicking on the metric name:

The Violations View (Remote and Local)
The Violations 
When switching to the Local mode, a local analysis will be run automatically.
At any time, to run another local analysis, right-click on the project, then select Sonar > Run Local Analysis:

Local Analysis Parameters
Parameters to configure local analysis can be set in various places. Here is the hierarchy of parameters:
- Parameters defined in the Sonar Web UI
- Parameters set in the pom.xml file (for Maven projects only, with the m2e connector installed) will override parameters defined in the UI
- Parameters defined in Eclipse will override parameters defined in the pom file (go to Window > Preferences > Sonar > Local analysis properties)
- Parameters defined at project level in Eclipse will override parameters defined at Eclipse level (right click on the project and go to Properties > Sonar > Local analysis properties)
| Info | ||
|---|---|---|
| ||
Some plugins (useless for a local analysis) can be skipped while performing a local analysis thanks to the 'sonar.dryRun.excludePlugins' property (Settings > Configuration > General Settings > General). The default value is 'devcockpit,pdfreport,report,scmactivity,views'. For example, to skip the Build Stability plugin (due to https://jira.codehaus.org/browse/SONARIDE-346), set the property to 'devcockpit,pdfreport,report,scmactivity,views,buildstability'. |
Last Analysis Date
There are two ways to know when the last analysis was run a project:
- Right-click on the project in the Project Explorer, and then Properties > Sonar
- This date can be displayed on the navigation views, like the Project explorer or the Navigator. This option is not active by default. To activate it, go to Window > Preferences > General > Appearance > Label Decorations and check Sonar Analysis Date Decorator:

Violations View (displays local or remote information depending on the selected mode)
The Violations view displays the list of violations of the selected resource (project, file, etc.):

The Hotspots View (Remote)
The Hotspots view allows to quickly identify hotspots on files according to favourite metrics (defined in the Measures view). You can for instance look at files with the greatest number of duplicated lines, the greatest number of violations, the greatest number of uncovered lines by unit tests, etc.

...

To refresh violations of resources from remote server, click on the Refresh button.
This view can be displayed by going to Window > Show View > Other... > Sonar > Violations.
Note that Problems and Markers views also display Sonar violations.
Web View (displays remote information only)
The Web view displays the web Sonar main project dashboard (for projects and packagesproject) or the web Sonar ressource resource viewer (for filesclass or file).
This web page can also be used to access information and services (cloudClouds, treemapHotspots, etc...) that are not yet natively available in Sonar Eclipse:

.
This view is automatically displayed when clicking on Sonar > Open in Sonar server. It can also be displayed by going to Window > Show View > Other... > Sonar > Web.


