OCLint 教程

OCLint 安裝方法

主要步驟

安裝GodEyes_iOS

參考 GodEyes官網(wǎng) http://godeyes.duapp.com/readme.jsp ,下載后無需安裝

1. 配置 GodEyes

打開 conf/config.ini 配置文件,根據(jù)你的項目需求,進(jìn)行如下設(shè)置:

1)?ProjectPath:要掃描的工程路徑,即擁有 xxx.xcodeproj 文件或 xxx.xcworkspace 的目錄

2)?xctoolCommand:這一步可能需要你費點心思。GodEyes 依賴一個叫做json編譯數(shù)據(jù)庫(json Compilation Database)的文件來獲取需要掃描的文件列表,而這個文件可以通過調(diào)用 GodEyes 內(nèi)置的第三方工具 xctool 來生成。然而,xctool 并不是很聰明,你需要告訴 xctool 一些關(guān)于你項目的必要信息,才能讓 xctool 正確生成編譯數(shù)據(jù)庫。以下是一個示例:

xctoolCommand = xctool/bin/xctool -project /HelloWorld.xcodeproj -scheme HelloWorld -sdk iphonesimulator -reporter json-compilation-database:/compile_commands.json clean build

2完成配置后,cd 進(jìn)入 godeyes 目錄,然后直接 sh main.sh 執(zhí)行腳本即可。

主要生成compile_commands.json,后面oclint要使用這個文件

2.GodEyes掃描規(guī)則

http://godeyes.duapp.com/scanrule.jsp

二。安裝oclint

下載oclint并安裝

下載地址:?http://oclint.org/downloads.html

選擇mac os x或者darwin的包,下載到本地。

打開~/.bash_profile,如果沒有新建一個,輸入

OCLINT_HOME=/path/to/oclint目錄

export PATH=$OCLINT_HOME/bin:$PATH

http://www.tuicool.com/articles/AnEnMzf

三。安裝xcpretty

https://github.com/supermarin/xcpretty

gem install xcpretty

四,集成到xcode

參考文檔http://docs.oclint.org/en/stable/guide/xcode.html

在 bin/sh 下面輸入

生成html報告

source ~/.bash_profile

cd ${SRCROOT}

xcodebuild clean

xcodebuild | xcpretty -r json-compilation-database

oclint-json-compilation-database oclint_args "-disable-rule=UnusedMethodParameter -disable-rule=LongLine -disable-rule=LongMethod -disable-rule=NcssMethodCount -disable-rule=ObjCObjectSubscripting -disable-rule=LongClass? -disable-rule=NcssMethodCount -disable-rule=NPathComplexity -disable-rule=NPathComplexity -rc LONG_VARIABLE_NAME=1200 " -- -report-type html? -o oclintReport.html

如果是在xcode里面看,改寫type

source ~/.bash_profile

cd ${SRCROOT}

xcodebuild clean

xcodebuild | xcpretty -r json-compilation-database

oclint-json-compilation-database oclint_args "-disable-rule=UnusedMethodParameter -disable-rule=LongLine -disable-rule=LongMethod -disable-rule=NcssMethodCount -disable-rule=ObjCObjectSubscripting -disable-rule=LongClass? -disable-rule=NcssMethodCount -disable-rule=NPathComplexity -disable-rule=NPathComplexity -rc LONG_VARIABLE_NAME=1200 " -- -report-type xcode

oclint_args "-disable-rule=UnusedMethodParameter -disable-rule=LongLine -disable-rule=LongMethod -disable-rule=NcssMethodCount -disable-rule=ObjCObjectSubscripting -disable-rule=LongClass? -disable-rule=NcssMethodCount -disable-rule=NPathComplexity -disable-rule=NPathComplexity -rc LONG_VARIABLE_NAME=1200 “

oclint_args指的是oclint 的檢測規(guī)則,-disable-rule 屏蔽某條規(guī)則

-rc LONG_VARIABLE_NAME=1200 制定某條規(guī)則的參數(shù)

參考文檔

http://oclint-docs.readthedocs.io/en/stable/rules/migration.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容