Once SonarQube has been installed, and you have installed an analyzer you are ready to run analyses on your projects. 

Scope of Analysis: Types of Files

SonarQube can perform analysis on 25+ different languages. The outcome of this analysis will be quality measures and issues (instances where coding rules were broken). However, what gets analyzed will vary depending on the language:

Scope of Analysis: Which Files

There are three different paradigms for SonarQube analysis: full analysis (or just plain "analysis"), preview analysis, and incremental analysis. You switch among the three modes using the sonar.analysis.mode analysis parameter with one of these three values:

Analysis Mode

Analysis mode performs a full analysis on the entire code base and saves the results to the database. Assuming code changes, you will ideally analyze once a day in this mode - typically over night. Use this mode to update the central server and keep the team at large abreast of your current code quality.

If you're using continuous integration, you don't want to add full analysis to your CI job. Doing so would cause needless churn in the SonarQube metrics and make the "Since previous analysis" differential nearly useless for most people. Instead, you'll want to set up a separate analysis job that polls your SCM on a nightly basis.

If you're not using continuous integration, but only building intermittently or at most daily, then by all means include SonarQube analysis in your regular build job.

Preview Mode

Preview mode performs a full analysis on the entire code base and does not save the results to the database. Typically this mode is used on the continuous integration server as part of the continuous integration job. To take full advantage of preview mode in this scenario, you'll want to install the Build Breaker Plugin, and set up a quality gate. Together, these two mechanisms allow you to automatically mark the build broken when the quality of newly checked in code is not up to standard. 

Incremental Mode

Incremental mode performs a fully analysis only on changed code, and does not save the results to the database. It is used on the developer's machine to check the quality of code changes before checking them in. It is the default in the Eclipse plugin. If you're not using Eclipse, you can still take advantage of incremental mode using a local installation of sonar runner and the Issues Report Plugin. In either case (Eclipse or Issues Report), you'll be able to see the issues on the code in question, with any issues introduced since the last full analysis highlighted for immediate attention.

Running Analysis

First, you should install the plugin(s) for the language(s) of the project to be analyzed, either by a direct download or through the update center.

Then, you need to choose an analysis method. The following are available:

Compatibility Matrix

This chart shows the backward compatibility of the current version of each analysis engine.

SonarQube Version

3.6

3.7
LTS

4.04.14.24.34.4
SonarQube Ant Task2.12.22.22.22.22.22.2
SonarQube Runner2.32.4

2.4

2.42.42.42.4
Maven2.2.x,
3.0.x
2.2.x,
3.0.x
3.1+ 
2.2.x,
3.0.x
3.1+ 
2.2.x,
3.0.x
3.1+ 
2.2.x,
3.0.x
3.1+ 
2.2.x,
3.0.x
3.1+ 
2.2.x,
3.0.x
3.1+ 

For more information

See also: