Skip to main content
Jump to: navigation, search

Analyzing ICE with SonarQube

This article is out of date for the 'next' branch. The new build structure does not currently contain a SonarQube build.

After completing the steps in the ICE Build Instructions, an additional Maven build may be executed to analyze the quality of the ICE source code using SonarQube. The development team recommends that the build be executed in Eclipse.

Create the Run Configuration

To create a custom run configuration to analyze all of the ICE source code, select Run > Run Configurations... from the menu bar. Alternatively, right-click on the pom.xml file in the top-level ICE directory in the Package Explorer, and select Run As > Run Configurations... from the context menu. In the Run Configurations dialog that appears, select Maven Build from the list on the left, and click the New launch configuration button near the top of this pane. Provide a name for the new configuration. Set the base directory to the org.eclipse.ice.aggregator directory. In the Goals: text field, enter sonar:sonar. Next to the parameter table in the dialog, click Add.... The dialog that appears allows you to set the names and values of parameters that appear in the pom.xml file. Unfortunately, we cannot widely distribute the values for these parameters, but if you need them, please send a request to eclipse.ice.project <at> gmail.com. After entering the parameters in the table, click Apply and then click Run.

ICESonarRunConf.png

View the Analysis Results

Following a successful execution of the run configuration, the full analysis results may be viewed in a web browser by visiting the URL provided by the development team.

ICESonarWebFull.png

Install SonarQube for Eclipse

Optionally, the SonarQube for Eclipse software may be installed in your workspace in order to view analysis results directly in Eclipse. This software may be installed using the Eclipse Marketplace or via Help > Install New Software... using the following site:

http://downloads.sonarsource.com/eclipse/eclipse/

The SonarQube C/C++ and Python Analyzers may be excluded for analyzing ICE’s source code, but the Java Analyzer and m2e Connector are required.

ICESonarInstall.png

Set the SonarQube Server

After installing the software, the SonarQube web server URL must be set in the Eclipse workspace preferences by selecting Window > Preferences from the menu bar. Expand SonarQube from the list on the left of the dialog, and select Servers. Edit the server address to the URL provided by the development team.

View Single Bundle Results

The results for a single bundle may be reviewed within Eclipse. To do this, right-click the bundle to review. Mouse over Configure, and select Associate with SonarQube. If a full analysis has been completed previously, the results on the server should be detected automatically, and clicking Finish is all that is required in the dialog that is displayed.

SonarQube Issues View
The previous step may open the SonarQube Issues view. If this view is not opened automatically, right-click the bundle again, mouse over SonarQube, and select Analyze. This view provides a collapsible list of all of the quality issues detected by SonarQube.

ICESonarIssuesView.png

SonarQube Web Browser View
To view the SonarQube results for a single bundle in a manner similar to the view available in the web browser version, right-click the bundle to be viewed, mouse over SonarQube in the context menu, and select Open in SonarQube Server.

ICESonarWebBrowser.png

Editor Flags
Finally, SonarQube issues can be viewed inline with the offending code directly in the editor window. SonarQube issues are marked in the gutter of the editor with the following icon:

ICESonarFlag.png

Copyright © Eclipse Foundation, Inc. All Rights Reserved.