iOS性能优化-检测工具OCLint

一、OCLint

OCLint is a static code analysis tool for improving quality and reducing defects by inspecting C, C++ and Objective-C code and looking for potential problems。
OCLint是一个静态代码分析工具,通过检查C,C ++和Objective-C代码,寻找潜在问题来提高质量并减少缺陷。

1、GitHub地址
2、官网地址


二、安装

1、安装xcpretty

sudo gem install xcpretty

2、安装OCLint

brew tap oclint/formulae
brew install oclint

Tips:
需要gem和Homebrew,请自行安装。


三、使用

官方文档

1、脚本

xcodebuild clean
xcodebuild archive -workspace yourProject.xcworkspace -scheme yourProject | tee xcodebuild.log |  xcpretty -r json-compilation-database -o compile_commands.json
oclint-json-compilation-database -e Pods -- \
        -max-priority-1=100000 \
        -max-priority-2=100000 -max-priority-3=100000 \
        -disable-rule=InvertedLogic \
        -disable-rule=CollapsibleIfStatements \
        -disable-rule=UnusedMethodParameter \
        -disable-rule=LongVariableName \
        -disable-rule=ShortVariableName \
        -disable-rule=UselessParentheses \
        -disable-rule=IvarAssignmentOutsideAccessorsOrInit | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/'

Tips:
xcodebuild archive改为build或者analyze,json-compilation-database为空,不知原因。
tee xcodebuild.log不是必要操作,可去除。


2、规则

过滤规则可以自定义,也可以使用官网定义过的规则。
官方文档

中文文档


3、持续集成

可将OClint集成至Jenkins。此处不赘述。


摘要

http://oclint.org
http://www.cocoachina.com/ios/20170928/20669.html
http://docs.oclint.org/en/stable/guide/xcpretty.html
http://docs.oclint.org/en/stable/rules/index.html
https://stackoverflow.com/questions/31447296/oclint-compile-commands-json-not-found-at-current-location/31449152
https://blog.csdn.net/liqinghuiyx/article/details/52414975

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值