Skip to end of metadata
Go to start of metadata

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 RunnerMaven or Ant) on your local machine. In configuring the analyzer, you only have to set the 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.propertiespom.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.

Short issues report in the console

Now, simply run:

sonar-runner -Dsonar.analysis.mode=preview -Dsonar.issuesReport.console.enable=true

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:

sonar-runner -Dsonar.analysis.mode=preview -Dsonar.issuesReport.html.enable=true

You will get 2 different HTML reports that look like the following example (you can download the full report here):

Some notes:

  • 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 sonar.issuesReport.lightModeOnly.
  • To define the location of the HTML reports, set the sonar.issuesReport.html.location property 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
    • target/sonar/issues-report/ for Maven
  • You can also configure the filename of the generated html reports using the property




  • No labels