Sonar is an amazing tool that you should check out if you haven't already. Start by looking at Sonar's analysis of its own code. I think most Sonar users have it running as part of a regular build process, such as a nightly build, and review the results via the web application. But sometimes you want faster feedback without the context-switching required when flipping between a web browser and your code. In these cases, Sonar's Eclipse plugin can be handy.
To install the plugin for Eclipse 3.7:
1. Select Help from the top menu bar and then select Install New Software…
2. An Install window will appear. Type "http://dist.sonar-ide.codehaus.org/eclipse/" in the Work With field and press enter. A Sonar component should appear in the list below. Expand the component and check the Sonar Integration for Eclipse (Required) checkbox and then press Next.
3. If Eclipse can install Sonar, the Finish button will become enabled. Press this button to install the plugin.
To configure the plugin:
1. You first must configure the location of your Sonar server. Choose Window and then Preferences. Choose Sonar from the listings on the left. An Add button will appear on the right, allowing you to add a new Sonar server.
2. Press the Add button. An Add Server Configuration window will appear. Enter the URL of your Sonar server instance, as well as a username and password, if needed. Then press Finish.
3. Using the Navigator or Package Explorer view, navigate to the project you want to analyze, right-click on it, and choose Configure and then Associate with Sonar…
4. An Associate with Sonar window will appear. Choose the Sonar server you configured from the top dropdown. Select the checkbox for the project you want analyzed, and enter the Maven GroupId and ArtifactId for your project. If you're not using Maven, then enter your Sonar projectName value for the GroupId and your version number for the ArtifactId. Then press Finish.
5. You can now open the Sonar perspective by choosing Window and then Open Perspective and then Other. An Open Perspective window will appear. Choose Sonar and then press OK.
The plugin's default behavior is to aggregate and display data from the Sonar server, forgoing any local analysis. This works great most of the time, but there are times when you're writing new code or modifying existing code so extensively that the data from the server is no longer useful. In these circumstances, you can opt to run a local analysis instead. The local analysis is just a subset of the analysis performed by the server, but it covers the big pieces and gives you a general sense of your code's quality.
To run a local analysis:
1. Right-click on your project from the Navigator or Package Explorer view and choose Sonar, then Analyse…, and then Locally.
2. Then right-click on the project and choose Sonar and Run Local Analysis.