sonar Analysis Parameters

来源:互联网 发布:淘宝网小蚊子店铺 编辑:程序博客网 时间:2024/06/05 14:09

source: http://docs.codehaus.org/display/SONAR/Analysis+Parameters

Table of Contents

  • Mandatory Parameters
    • Server
    • Database
    • Project Configuration
  • Optional Parameters
    • Project Configuration
    • Configuration
    • Log

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

  • Global analysis parameters, defined in the UI, will apply to all the projects
  • Project analysis parameters, defined in the UI, will override global parameters
  • Project analysis parameters, defined in project analysis configuration file or in analyzer configuration file, will override the ones defined in the UI
  • 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 the sonar.profile parameter via command line for a specific project, it will not be stored in the database. Then, a local analysis in Eclipse will 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 source code. If a plugin allows to analyze another language, the associated source code analyser can be activated with this property.

java

sonar.sources

Comma-separated paths to directories containing sources.
Not compatible with Maven: source code retrieved from default location for Java Maven projects. 

 

Optional Parameters

Project Configuration

Key

Description

Default value

sonar.projectDescription

Description of the project.
Set through <description> when using Maven. 

 sonar.binaries

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

 sonar.tests

Comma-separated paths to directories containing tests.
Not compatible with Maven: tests retrieved from default location for Java Maven projects.  

 sonar.libraries

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

Example:

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

Note that * wildcard character is not supported for directories (only for files).

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

 

sonar.sourceEncoding

Encoding of source files. Example of values: UTF-8, MacRoman, Shift_JIS. This property can be replaced by the standard propertyproject.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

Sometimes, for security or other reasons, project sources must not be stored and displayed.

true

sonar.projectDate

When starting to analyze a new project, you may want to feed your SonarQube instance with the quality snapshots of the last versions of this project. In order to get some information on quality trend over the last 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, you will lose your whole history. So, you may also want to feed the new SonarQube instance with some historical data.

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

The process is the following:

  • Retrieve a specific version of the source code of your application from the SCM (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 version of the source code of your application from the SCM 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 in chronological order to the newest one.

 

Current date

sonar.exclusions

Exclude files from analysis. See Project Administration#ExcludingFiles for more details. This page also details sonar.tests.exclusionssonar.inclusions,sonar.tests.inclusionssonar.global.exclusionssonar.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.

 

sonar.branch

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

 

sonar.profile

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.

Default profile for the given language

sonar.skipDesign

To 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, those unit tests are executed but you can optionally decide to do only static analysis or to reuse existing reports which have been previously generated. Possible values are truefalsereuseReports.

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

true

sonar.working.directory

To set the working directory for the SonarQube Runner or the SonarQube Ant Task (versions greater than 2.0).

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

Log

KeyDescriptionDefault valuesonar.showProfilingDisplay logs to know where time is spentfalsesonar.showSqlDisplay all the SQL requests executed on batch sidefalsesonar.showSqlResultsDisplay the result of all SQL requests executed on batch sidefalsesonar.verboseActivation of the DEBUG mode on batch sidefalse
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 头不自觉向右偏怎么办 靠墙站立腰疼怎么办 小腿酸痛乏力肌肉萎缩怎么办 搬重物后手臂疼怎么办 和尚鹦鹉吃了盐怎么办 刚买鹦鹉不上手怎么办 word的文件时间改了怎么办 图强gps编码丢失怎么办 武统台湾后岛民怎么办 没有你我怎么办是什么歌 ios 12软件闪退怎么办 来大姨妈想吐怎么办 3岁宝宝体重轻怎么办 硕士延期毕业考上博士怎么办 中国人移民欧洲饮食不习惯怎么办 出车祸了报警警察不管怎么办 高中的孩子不好好上学怎么办 和老公消费观念不合拍怎么办 去医院没带现金怎么办 微信读书下架了怎么办 24岁血压有点高怎么办 吃鸡鼠标弹出来怎么办 电脑分辨率调错了怎么办 猎豹sc9打不开门怎么办 苹果手机卡顿反应慢怎么办 金立手机卡顿反应慢怎么办 20天宝宝黄疸219怎么办? 智慧树选修挂科怎么办 军人被纠察抓了怎么办 我家的小孩很凶怎么办 10岁儿童老挤眼怎么办? 脚趾长鸡眼好痛怎么办 月加班超过36小时怎么办 月经老提前怎么办才好 20岁例假不规律怎么办 农村的医保门诊封顶了怎么办 保研夏令营被拒怎么办 小学生去英国游学怎么办签证 医生说我湿气重怎么办 喉咙痛有来医生感冒喉咙痛怎么办 暴马丁香叶子卷怎么办