See https://docs.sonarqube.org/display/SONAR/Documentation for current functionality
When running an analysis in preview mode, the SonarQube platform provides the ability to generate a report of issues so developers can see whether they're about to inject new technical debt before submitting their new code. This way, they can make sure they're not committing code with new issues, and therefore that no new technical debt will be reported on the SonarQube server after the next full analysis.
You do not need to install a SonarQube server on your local machine. You only need to install your favorite analyzer (SonarQube Scanner, SonarQube Scanner for Maven, or SonarQube Scanner for Ant) on your local machine. In configuring the analyzer, you only have to set the
sonar.host.url property to point to your remote SonarQube server. Connection settings for the SonarQube database aren't needed for preview analysis because no data is pushed to the database.
If you don't have it locally, copy the configuration file (sonar-project.properties, pom.xml, etc.) that is used to analyze the project to your local machine, and update
sonar.sources to refer to the directory containing the source code on your machine.
The tree structure of the source code on your local machine must match the tree structure that has been remotely analyzed by SonarQube.
Below, are details about getting reports. Note that the reporting options are controlled by setting property values. We demonstrate setting those values on the command line, but they can also be set in the analysis configuration file (e.g. sonar-project.properties).
Short issues report in the console
Now, simply run:
You will get something like the following result at the end of your preview analysis:
Detailed issues report in a dedicated HTML file
Having a short console summary is fine, but in most cases you want more details when new issues are found. To get it, simply replace "
console" by "
html" in the previous command line:
You will get 2 different HTML reports that look like the following example (you can download the full report here):
- By default 2 html reports are generated:
- The full report (default name is issues-report.html)
- The light report (default name is issues-report-light.html) that only contains new issues.
- The light report is useful when working on legacy projects with many issues, since the full report may be hard to display in your web browser. You can skip full report generation using property
- To define the location of the HTML reports, set the
sonar.issuesReport.html.locationproperty to an absolute or relative path to the destination folder for the HTML report. The default values are
.sonar/issues-report/for the SonarQube Runner and Ant
- You can also configure the filename of the generated html reports using the property