使用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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM