初识Sonar——代码质量管理平台

2018-05-14  本文已影响0人  treeph

Sonar介绍

Sonar是一个用于代码质量管理的开放平台。

SonarQube搭建

# 数据库用户名密码
sonar.jdbc.username=sonar
sonar.jdbc.password=123456

# 我用的是mysql。如果是Oracle/PostgreSql/SQLServer,打开相应注释即可
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false

# 默认端口9000,可修改
sonar.web.port=9000
InstallNTService.bat
StartNTService.bat
StartSonar.bat

Sonar Scanner扫描

Sonar通过SonarQube Scanner对代码进行扫描和分析。

#----- Default SonarQube server
sonar.host.url=http://localhost:9000
# must be unique in a given SonarQube instance
sonar.projectKey=doc-parser
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=doc-parser
sonar.projectVersion=1.0
 
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set. 
sonar.sources=.
 
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

2)启动扫描
在项目路径下,执行sonar-scanner命令启动scanner。

Sonar Web可视化

扫描完成后,即可在http://localhost:9000上看到分析结果,接下来就是去分析问题和优化代码啦。

overview
issues详情
上一篇 下一篇

猜你喜欢

热点阅读