Sonar 代码质量管理

# Sonar 代码质量管理

Sonar 是一个用于代码质量管理的开放平台。通过插件机制,Sonar 可以集成不同的测试工具,代码分析工具,以及持续集成工具。

# Sonar 安装

官网地址 https://www.sonarqube.org/
从官网下载zip包并解压

# Sonar 配置

* 配置Sonar使用mysql数据库
创建 table sonar;
修改 conf/sonar.properties
'''
sonar.jdbc.username=root
sonar.jdbc.password=root
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
'''

* Sonar 启动
bin/linux-x86-64/sonar.sh start

# 安装的插件

* chinese Pack
* SonarJava
* SonarPython
* SonarJS
* Findbugs

# 代码检查
使用 sonar-scanner
下载 sonar-scanner-cli-3.0.3.778-linux.zip
配置 conf/sonar-scanner.propertie
'''
sonar.host.url=http://10.201.10.128:9000
sonar.jdbc.url=jdbc:mysql://127.0.0.1:3306/sonar?useUnicode=true&characterEncoding=utf8
sonar.jdbc.username=root
sonar.jdbc.password=root
sonar.login=admin
sonar.password=admin

'''

在代码根目录
配置 sonar-project.properties
'''
# must be unique in a given SonarQube instance
sonar.projectKey=test:master
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=script-scanner
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
sonar.language=java

'''

sonar.projectKey 需要在 sonarqube 中创建唯一key

配置环境变量
vi /etc/profile
'''
export PATH=${PATH}:xxxxxx

'''

source /etc/profile

启动 sonar-scanner

访问 http://127.0.0.1:9000 查看项目检查情况


没研究明白iteye的md 后续补图
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值