sonar入门(使用)

上篇文章己经介绍如何安装sonarqube. 传送门(http://blog.csdn.net/wandrong/article/details/77574942)


sonarqube只是一个代码质量规则管理的一个“库”,扫描分析我们的代码时还需要用sonar-scanner


sonar-scanner和sonarqube有版本上的依赖,本文例子基于 sonarqube-6.3和sonar-scanner-2.8  (sonarqube 4+版本后 sonar-scanner对应版本好像起码得2.4+)


sonar-scanner-2.8 : https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-2.8.zip


首先将sonar-scanner下载,并解压出来


然后需要配置环境配量

新增一个变量SONAR-RUNNER,值为sonar-scanner的解缩地址,如E:\Program File\sonar-scanner-2.8

然后在PATH变量后面追加%SONAR-RUNNER%\bin;


现在我们可以打开命令行测试是否配置成功

sonar-runner -v
WARN: sonar-runner.bat script is deprecated. Please use sonar-scanner.bat instead.
E:\Program File\sonar-scanner-2.8\bin\..
INFO: Scanner configuration file: E:\Program File\sonar-scanner-2.8\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: D:\workspaces\TspSend\sonar-project.properties
INFO: SonarQube Scanner 2.8
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
INFO: Windows 7 6.1 amd64


关于该命令参数可以用 sonar-runner -h 查看


现在我们可以开始要为我们的代码扫描编写一个执行的配置文件

在你的项目工程目录新建一个文件,名为sonar-project.properties

# must be unique in a given Sonar

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值