Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

  • Global analysis parameters, defined in the UI, will apply to all the projects (From the top bar, go to Settings > General Settings)
  • Project analysis parameters, defined in the UI, will override global parameters (At project level, go to Configuration > Settings)
  • Project analysis parameters, defined in a project analysis configuration file or in an analyzer configuration file, will override the ones defined in the UI
  • Analysis / Command line parameters, defined when launching an analysis, will override project analysis parameters

...

Note that only parameters set through the UI are stored in the database.
For example, if you set override the sonar.profile parameter via command line for a specific project, it will not be stored in the database. Then, a local analysis Local analyses in Eclipse will , for example, would still be run against the default quality profile.

...

Key

Description

Default value

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

...

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 . If a plugin allows to analyze another language, the associated source code analyser can be activated with this property.javato analyze. Browse the Plugin Library page to get the list of all available languages. If not set, a multi-language analysis will be triggered.

 

sonar.sources

Comma-separated paths to directories containing sourcessource files.
Not compatible Compatible with Maven : since SonarQube 4.2. If not set, the source code is retrieved from the default location for Java Maven projectsMaven source code location

 

Optional Parameters

Project Configuration

Key

Description

Default value

sonar.projectDescription

Description of the The project description.
Set through <description> when using Maven. Not compatible with Maven, which uses the <description> attribute.

 
sonar.binaries

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

 
sonar.tests

Comma-separated paths to directories containing tests.
Not compatible with Maven: tests retrieved from , 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: JAR files). Pattern Patterns can be used.

Example:

Code Block
languagenone
sonar.libraries=path/to/specific/library/myLibrary.jar,path/to/library/*.jar

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 engine 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. and , thus getting more accuracy during issues issue detection.

 
sonar.analysis.mode

Set the analysis mode. See Concepts.

Possible values:

  • analysis
  • preview
  • incremental
analysis

Anchor
parameterSourceEncoding
parameterSourceEncoding
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.importSourcesSometimes, for

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

Anchor
parameterProjectDate
parameterProjectDate
sonar.projectDate

When starting to analyze a 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
feed your SonarQube instance with the quality snapshots of the last versions of this project. In
  • retroactively create some history for the project in order to get some information on quality
trend
  • 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
this case
  • doing so, you will lose
your whole history. So,
  • the entire history for all your projects. Which is why you may
also
  • want to feed the new SonarQube
instance
  • database with some historical data.

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

The process is the following:

  • Retrieve a specific the oldest version of the source code of your application from the SCM '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 another the next version of the source code of your application from the SCM , update the sonar.projectDate property, and run another analysis by properly setting the sonar. projectDate property. And so on for all the versions of your application you're interested in.
Note: first analyze the latest version and then move You must analyze your versions in chronological order to the newest one, oldest first.

 

Current date

sonar.exclusions

Exclude files from analysis. See Project Administration for more details. This page also details sonar.tests.exclusions, sonar.inclusions, sonar.tests.inclusions, sonar.global.exclusions, sonar.global.tests.exclusions.

 

sonar.skippedModules

Some project modules should not be analyzed and consolidated with global project measures, for instance samples, integration tests or generated code.
If a module's artifactId differs from its module name (the directory name): it is the artifactId that should be use instead of the module name. Format is a comma-separated list of modules: module1_to_exclude,module2_to_exclude.

 

sonar.includedModules

Comma-separated list of the modules to analyse, all other modules are automatically ignored. Be careful: the root project must be added to the list.
If a module's artifactId differs from its module name (the directory name): it is the artifactId that should be use instead of the module name.

 

Anchor
parameterBranch
parameterBranch
sonar.branch

Manage SCM branches. Two branches of the same project are considered as 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

To skip Skip the computation of design metrics and dependencies.

Currently only available for Java.

false

sonar.phase

When SonarQube needs a Maven phase or goal to be executed prior to the analysis, this parameter can be used. For example sonar.phase=generate-sources. This property is used only for Maven analysis.

 

sonar.dynamicAnalysis

Dynamic analysis relates to unit tests. 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

Anchor
workingDirectory
workingDirectory
sonar.working.directory

To set 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 running each analysis.

.sonar

Configuration

Key

Description

Default value

sonar.host.connectTimeoutMs sonar.host.readTimeoutMs

Increasing HTTP timeouts of requests to server. The Maven plugin executes some HTTP requests to the server. Two timeouts makes the call fails 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

Exclusions / Inclusions

See Narrowing the Focus to:

  • Exclude files from analysis
  • Prevent some files from being checked for duplications
  • Prevent some files from being taken into account for code coverage by unit tests and integration tests
  • Ignore issues on certain components and against certain coding rules

Analyzer's Log

KeyDescriptionDefault value
sonar.showProfilingDisplay logs to know see where the analyzer spends time is spent.false
sonar.showSqlDisplay all the SQL requests executed on batch sidequeries executed by the analyzer.false
sonar.showSqlResultsDisplay the result results of all the SQL requests executed on batch sidequeries executed by the analyzer.false
sonar.verboseActivation of the Activate DEBUG mode on batch sidefor the analyzer.false