OC静态代码检查

OC静态代码检查

准备阶段

oclint的安装

1.安装Homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2.安装OCLint

brew tap oclint/formulae
brew install oclint

安装 xcpretty

gem install xcpretty

在xcode里查看结果

1.创建Aggregate类型的Target

2.Build Phases 选项卡中选择 Add Run Script

3.拷贝脚本

source ~/.bash_profile
cd ${PROJECT_DIR}
xcodebuild clean
xcodebuild| xcpretty -r json-compilation-database -o compile_commands.json
oclint-json-compilation-database -report-type xcode
//也可以在xcodebuild后添加参数

读懂扫描报告

OCLint Report Summary: TotalFiles=6 FilesWithViolations=2 P1=0 P2=1 P3=10 /Users/issuser/Desktop/OCLintTest/OCLintTest/ViewController.m:29:5: dead code [basic|P2] /Users/issuser/Desktop/OCLintTest/OCLintTest/ViewController.m:19:5: short variable name [naming|P3] Length of variable name `i` is 1, which is shorter than the threshold of 3 
...
/*
报告显示:共扫描了6个文件,其中有问题的文件数2个。
p1:1级为0个
p2: 2级为1个(从下面的代码可以看出为dead code),类似于在return语句后写的代码
p3: 3级为10个,该级别比较低。例如一行写的代码超过100个字符就会被列为3级。 
*/
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值