Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 148 Next »

Table of Contents

Parameters to configure project analysis can be set in multiple places. Here is the hierarchy of parameters:

  • Global analysis parameters, defined in the UI, apply to all the projects
  • Project analysis parameters, defined in the UI, override global parameters
  • Project analysis parameters, defined in a project analysis configuration file or an analyzer configuration file, override the ones defined in the UI
  • Analysis / Command line parameters, defined when launching an analysis, override project analysis parameters
Note that only parameters set through the UI are stored in the database.
For example, if you override the sonar.profile parameter via command line for a specific project, it will not be stored in the database. Local analyses in Eclipse, for example, would still be run against the default quality profile.

Mandatory Parameters

Server

Key

Description

Default value

sonar.host.urlServer URLhttp://localhost:9000

Database

Key

Description

Default value

sonar.jdbc.url

JDBC Connection URL

jdbc:h2:tcp://localhost:9092/sonar

sonar.jdbc.username

User for the JDBC Connection

sonar

sonar.jdbc.password

Password for the JDBC Connection

sonar

Project Configuration

Key

Description

Default value

sonar.projectKey

The project key that is unique for each project.
Set through <groupId>:<artifactId> when using Maven.

 
sonar.projectName

Name of the project that will be displayed on the web interface.
Set through <name> when using Maven.

 
sonar.projectVersion
The project version.
Set through <version> when using Maven.
 

sonar.language

Set the language of the source code to analyze. Browse the Plugin Library page to get the list of all available languages.

java

sonar.sources

Comma-separated paths to directories containing source files.
Not compatible with Maven, which retrieves the source code from the default location for Java Maven projects. 

 

Optional Parameters

Project Configuration

Key

Description

Default value

sonar.projectDescription

The project description.
Not compatible with Maven, which uses the <description> attribute.

 
sonar.binaries

Comma-separated paths to directories containing the binary files (directories with class files, in the case of Java).
Not compatible with Maven, which retrieves binaries from the default location for Java Maven projects. 

 
sonar.tests

Comma-separated paths to directories containing tests.
Not compatible with Maven, which retrieves test from the default location for Java Maven projects.  

 
sonar.libraries

Comma-separated paths to files with third-party libraries (JAR files in the case of Java). Patterns can be used.

Example:

Note that the * wildcard character is not supported for directories, only for files.

This property is used by rule engines during issues detection (mainly the SonarQube and FindBugs engines, which both rely on bytecode). Having the bytecode of these libraries allows the rules engines to get more information on coupling, possible null parameters when calling external APIs, etc., thus getting more accuracy during issue detection.

 
sonar.analysis.mode

Set the analysis mode. See Concepts.

Possible values:

  • analysis
  • preview
  • incremental
analysis

sonar.sourceEncoding

Set the source file encoding.

Encoding of source files. Example of values: UTF-8, MacRoman, Shift_JIS. This property can be replaced by the standard property project.build.sourceEncoding in Maven projects.

The list of available encodings depends on your JVM. See http://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html.

System encoding

sonar.importSources

Allow or suppress the import of the text of source files into SonarQube.

For security or other reasons there are times when project sources must not be stored and displayed. Set this value to false to prevent the text of a project's source files from being available via the SonarQube interface to anyone at all.

true

sonar.projectDate

Assign a date to the analysis.

Note: This parameter is applicable to a few, special use cases, rather than being an "every day" parameter:

  • When analyzing a new project, you may want to retroactively create some history for the project in order to get some information on quality trends over the last few versions.
  • When moving from one database engine to another, it is highly recommended (even mandatory) to start from a fresh new database schema. In doing so, you will lose the entire history for all your projects. Which is why you may want to feed the new SonarQube database with some historical data.

To answer those use cases, you can use the sonar.projectDate property. The format is yyyy-MM-dd, for example: 2010-12-01.

The process is the following:

  • Retrieve a the oldest version of your application's source that you wish to populate into the history (from a specific tag, whatever).
  • Run a SonarQube analysis on this project by setting the sonar.projectDate property. Example: sonar-runner -Dsonar.projectDate=2010-12-01
  • Retrieve the next version of the source code of your application, update the sonar.projectDate property, and run another analysis. And so on for all the versions of your application you're interested in.
Note: You must analyze your versions in chronological order, oldest first.

Current date

sonar.branch

Manage SCM branches. Two branches of the same project are considered to be different projects in SonarQube.

 

sonar.profile

Override the profile that would normally be used to analyze a project.

Through the web interface, you can define as many quality profiles as you want, and you can easily associate one of these quality profiles to a given project though the web interface.

Default profile for the given language

sonar.skipDesign

Skip the computation of design metrics and dependencies.

Currently only available for Java.

false

sonar.phase

Execute a Maven phase or goal prior to the analysis.

For example sonar.phase=generate-sources. This property is used only for Maven analysis.

 

sonar.dynamicAnalysis

Enable or disable the execution of unit tests during the analysis.

By default (true) unit tests are executed during a SonarQube analysis. But you can either decide to not execute them (false) or reuse existing reports which have been previously generated (reuseReports).

See the Code Coverage by Unit Tests tutorial for details and examples.

true

sonar.working.directory

Set the working directory for an analysis triggered with the SonarQube Runner or the SonarQube Ant Task (versions greater than 2.0).

Path must be relative and unique for each project.

Beware: the specified folder is deleted before each analysis.

.sonar

Exclusions / Inclusions

The below properties are detailed on the Narrowing the Focus documentation page.

Key

Description

Default value

sonar.exclusions

Exclude files from analysis. See also sonar.test.exclusions, sonar.inclusions, sonar.test.inclusions, sonar.global.exclusions, sonar.global.test.exclusions, sonar.skippedModules, sonar.includedModules

 

sonar.cpd.exclusionsPrevent some files from being checked for duplications. 
sonar.coverage.exclusionsPrevent some files from being taken into account for code coverage by unit tests and integration tests. 
sonar.issue.ignore.allfileIgnore issues on certain components and against certain coding rules. See also sonar.issue.ignore.block, sonar.issue.ignore.multicriteria, sonar.issue.enforce.multicriteria. 

Configuration

Key

Description

Default value

sonar.host.connectTimeoutMs sonar.host.readTimeoutMs

Increase the HTTP timeouts of requests to server. The Maven plugin executes some HTTP requests to the server. Two timeouts makes the call fail if the server connection is too slow. In such a case the timeouts can be increased from Maven properties.

Respectively 30,000 and 60,000 milliseconds

Log

KeyDescriptionDefault value
sonar.showProfilingDisplay logs to see where analysis time is spentfalse
sonar.showSqlDisplay all the SQL requests executed on batch sidefalse
sonar.showSqlResultsDisplay the results of SQL requests executed on batch sidefalse
sonar.verboseActivate DEBUG mode on batch sidefalse
  • No labels