使用OCLint和Sonar对iOS代码分析和质量管理

OCLint 是一个强大的静态代码分析工具,可以用来提高代码质量,查找潜在的bug,主要针对c,c++和Objective-c的静态分析。

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

1.检查你的电脑有没有安装brew

  如果没有安装,会显示什么呢 -bash:brew:command not found

  该怎么办呢?

  打开终端  执行 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2.SonarQube安装

  说明:此处略过java,mysql,jenkins安装配置。

  安装java : http://www.oracle.com/technetwork/java/javase/downloads/index.html

 

   brew install sonarqube                                                                                                       

   SonarQube汉化

    汉化插件

   https://github.com/SonarQubeCommunity/sonar-l10n-zh

 

   下载后放入 如下目录:

   /usr/local/Cellar/sonarqube/6.5/libexec/extensions/plugins                                                


 3.
Mysql安装

    brew install mysql                                                                                                              

  记得启动mysql服务:mysql.server start        

4.创建sonar数据库

 

5.配置sonar连接mysql

 

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
 
sonar.jdbc.username=root
 
sonar.jdbc.password=root
 
sonar.sorceEncoding=UTF-8
 
sonar.login=admin
 
sonar.password=admin

 

6.安装xcpretty

  gem install xcpretty

7.安装OCLint

 

  brew tap oclint/formulae

  brew install oclint

8.安装sonar-scanner

  brew install sonar-scanner

9.安装sonar-objective-c-plugin

  下载后放入如下目录:/usr/local/Cellar/sonarqube/6.5/libexec/extensions/plugins

 

10.重启sonar

  sonar restart

  到此Sonar环境已经基本配置好了,打开 http://127.0.0.1:9000

 

posted @ 2018-02-08 17:50  iOS张文权  阅读(2554)  评论(0编辑  收藏  举报