使用OCLint和Sonar對iOS代碼分析和質量管理

OCLint 是一個強大的靜態代碼分析工具,能夠用來提升代碼質量,查找潛在的bug,主要針對c,c++和Objective-c的靜態分析。html

Sonar 是一個用於代碼質量管理的開放平臺。經過插件機制,Sonar 能夠集成不一樣的測試工具,代碼分析工具,以及持續集成工具。java

1.檢查你的電腦有沒有安裝brewmysql

  若是沒有安裝,會顯示什麼呢 -bash:brew:command not foundc++

  該怎麼辦呢?git

  打開終端  執行 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"github

2.SonarQube安裝objective-c

  說明:此處略過java,mysql,jenkins安裝配置。sql

  安裝java : http://www.oracle.com/technetwork/java/javase/downloads/index.html數據庫

 

   brew install sonarqube                                                                                                       
ruby

   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

相關文章
相關標籤/搜索