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)
通过插件形式,可以支持包括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)
相关文章推荐
- 从源码安装Mysql/Percona 5.5
- 在 AppImage、Flathub 和 Snapcraft 平台上搜索 Linux 应用
- 解决vc中unable to connect to the MKS:Internal error问题
- 杰奇一些安装详细说明文件,比官方更细
- 无线网卡安装DIY
- 网卡安装常见问题精解
- DB2数据库的安装
- CentOS下DB2数据库安装过程详解
- ghost安装系统软件硬盘安装器 安装ghost图文教程
- CentOS 6.3下编译安装Ruby 2.0笔记
- FREEBSD安装POSTGRESQL笔记
- Redis总结笔记(一):安装和常用命令
- FreeBSD 6.2 安装全程图解教程
- 安装Apache和PHP的一些补充
- Lua在windows下的安装及环境配置
- PHP 5.3.0 安装分析心得
- 关于MSSQL 2005的安装与补丁
- sql2008安装教程 SQL Server 2008 R2 安装图解
- 无法在com+ 目录中安装和配置程序集 错误:-2146233087的解决方法[已测]
- PostgreSQL 安装和简单使用第1/2页