sonar.jdbc.url mysql_AndroidStudio下使用SonarQube使用心得

SonarQube 是一个代码质量管理的平台,关于平台的配置方法很多,但是用于Android Studio的相关文档真心不多,使用方法:

1 本地进行代码审查:(使用AS的插件)

缺点:无法同步到服务器并形成图表和文档

优点:方便在AS中进行跟踪定位

该使用方法过于简单不进行描述

2 可以将结果同步到服务器的方式:(与AS关系不大,属于通用的方式)

优点:可以形成图表,上传到服务器后方便统一管理

缺点:需要下载sonar—runner,配置环境变量(非必要手段),没有插件操

作方便

使用方法:

2. 配置 sonar-runner的config

f37b97a9f85c

image.png

3. 具体配置

#Configure here general information about the environment, such as SonarQube DB details for example

#No information about specific project should appear here

#----- Default SonarQube server

sonar.host.url=http://xxx.xxx.xxx.xxx:9000

#----- PostgreSQL

#sonar.jdbc.url=jdbc:postgresql://localhost/sonar

#----- MySQL

sonar.jdbc.url=jdbc:mysql://xxx.xxx.xxx.xxx:3306/sonar?useUnicode=true&characterEncoding=utf8

#----- Oracle

#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE

#----- Microsoft SQLServer

#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor

#----- Global database settings

sonar.jdbc.username=sonar

sonar.jdbc.password=sonar@2018

#----- Default source code encoding

sonar.sourceEncoding=UTF-8

#----- Security (when 'sonar.forceAuthentication' is set to 'true')

sonar.login=admin

sonar.password=admin

4. 在被检查项目的根目录创建 sonar-project.properties文件

f37b97a9f85c

image.png

5. 进行配置

# Required metadata

# key 和 name 就是创建项目时输入的字段,这里填写自己的项目name和key,其他不用管。

sonar.projectKey=Android

sonar.projectName=Android

sonar.projectVersion=1.0

# Path to the parent source code directory.

# 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=app/src

# Encoding of the source code

sonar.sourceEncoding=UTF-8

# Additional parameters

sonar.my.property=value

sonar.java.binaries=app/build/intermediates/classes

6. 编译

f37b97a9f85c

image.png

1.这里报错是因为没有找到对应的classes(我把项目给clearn了)

2.这里是在项目的根目录下打开终端(cmd)执行之前下载好的sonar-runner的bin目录下的sonar-runner

7. Success:

f37b97a9f85c

image.png

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值