iOS codeview

本文介绍如何在Mac环境下配置Xcode及安装xcpretty,并通过xcodebuild和OCLint进行代码静态分析的过程。针对可能出现的ruby版本问题提供了解决方案,同时分享了如何生成并处理compile_commands.json文件,以及OCLint默认规则的链接。

1.环境配置

oclint:http://oclint.org/

xcpretty:https://github.com/supermarin/xcpretty

 

使用Mac安装xcpretty过程可能会出现自带ruby版本错误,需要升级ruby

 

$ curl -L get.rvm.io | bash -s stable
$ source ~/.rvm/scripts/rvm
$ rvm list known
$ rvm install 2.2.0
rvm use 2.2.0 --default 

 

2.代码扫描

xcodebuild clean build -sdk iphonesimulator -arch "x86_64" ONLY_ACTIVE_ARCH=NO VALID_ARCHS="i386 x86_64" | xcpretty -r json-compilation-database
cp build/reports/compilation_db.json compile_commands.json
oclint-json-compilation-database -e Pods -- -rc=LONG_LINE=200 -rc=NCSS_METHOD=100 -o=report.html

如果扫描的生成的compile_commands.json文件过大,oclint-json-compilation-database会提示出错“OSError: [Errno 7] Argument list too long

https://github.com/oclint/oclint/issues/233有网友给出解决方案:https://github.com/wuwen1030/oclint_argument_list_too_long_solution/tree/master

 

3.oclint默认的rule

http://docs.oclint.org/en/stable/howto/thresholds.html

 

转载于:https://www.cnblogs.com/geweb/p/codeview.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值