AndroidStudio下使用SonarQube使用心得

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

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

  缺点:无法同步到服务器并形成图表和文档
  优点:方便在AS中进行跟踪定位

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

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

  优点:可以形成图表,上传到服务器后方便统一管理
  缺点:需要下载sonar—runner,配置环境变量(非必要手段),没有插件操            
  作方便

使用方法:

1.下载 sonar-runner 包:http://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-dist/
2. 配置 sonar-runner的config
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文件
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. 编译
image.png
1.这里报错是因为没有找到对应的classes(我把项目给clearn了)
2.这里是在项目的根目录下打开终端(cmd)执行之前下载好的sonar-runner的bin目录下的sonar-runner
7. Success:
image.png
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,282评论 19 139
  • 新晋测试小白最近在研究sonarqube的静态代码检查,整理了关于sonarqube 如何在mac os x系统下...
    测试小白_stone阅读 6,117评论 0 1
  • 1.SonarQube Sonar的功能:是一个用于代码质量管理的开源平台,用于管理源代码的质量,可以从七个维度检...
    Broom阅读 13,136评论 0 6
  • 著名学者史莱克曾经有一句名言:洋葱是分层次的,怪物也一样。 不管你承认不承认,尽管从政治正确的角度来说,人性共通,...
    霍真布鲁兹老爷阅读 10,886评论 29 223
  • 龚紫琳 18998720200 王子和公主的故事终于走到了最后一步,他们决定在卡尔加里山顶上举行婚礼。 在拍照过程...
    金伍仁阅读 2,607评论 0 0

友情链接更多精彩内容