您的位置:首页 > 编程语言

SonarQube快速安装

2016-04-08 00:00 477 查看
摘要: Sonar是一个用于代码质量管理的开源平台,用于管理源代码的质量,可以从七个维度检测代码质量
通过插件形式,可以支持包括java,C#,C/C++,PL/SQL,Cobol,JavaScrip,Groovy等等二十几种编程语言的代码质量管理与检测。
1.糟糕的复杂度分布
2.重复
3.缺乏单元测试
4.没有代码标准
5.没有足够的或者过多的注释
6.潜在的bug
7.糟糕的设计(原文Spaghetti Design,意大利面式设计)

# [SonarQube](http://www.sonarqube.org/ "SonarQube") #

## Get Started ##

1. [Download](http://www.sonarqube.org/downloads/ "Down") and unzip the SonarQube distribution (let's say in "C:\sonarqube" or "/etc/sonarqube")

2. Start the SonarQube server:

# On Windows, execute:
C:\sonarqube\bin\windows-x86-xx\StartSonar.bat

# On other operating system, execute:
/etc/sonarqube/bin/[OS]/sonar.sh console

3. [Download](http://docs.sonarqube.org/display/SONAR/Installing+and+Configuring+SonarQube+Scanner "Download") and unzip the SonarQube Scanner (let's say in "C:\sonar-runner" or "/etc/sonar-runner")

4. Update the global settings (server URL) by editing <install_directory>/conf/sonar-runner.properties:

#----- Default SonarQube server
#sonar.host.url=http://localhost:9000

5. Create a new SONAR_RUNNER_HOME environment variable eg:

SONAR_RUNNER_HOME = D:\Program Files\sonarqube\sonar-runner-2.4

6. Add the 'install_directory'/bin directory to your path eg:

${SONAR_RUNNER_HOME}/bin (Unix) or %SONAR_RUNNER_HOME%/bin

7. You can check the basic installation by opening a new shell and executing the command sonar-runner -h (on Windows platform the command is sonar-runner.bat -h) . You should get a message like this:

usage: sonar-runner [options]

Options:
-D,--define <arg> Define property
-e,--errors Produce execution error messages
-h,--help Display help information
-v,--version Display version information
-X,--debug Produce execution debug output

8. Create a configuration file in the root directory of the project: sonar-project.properties

**sonar-project.properties**

# must be unique in a given SonarQube instance
sonar.projectKey=my:project
# this is the name displayed in the SonarQube UI
sonar.projectName=My project
sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
9. Run the following command from the project base directory to launch the analysis:

sonar-runner

10. Browse the results at [http://localhost:9000](http://localhost:9000 "http://localhost:9000") (default System administrator credentials are admin/admin)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息