静态代码扫描--OCLint

来源:互联网 发布:cda数据分析师教程 编辑:程序博客网 时间:2024/05/01 23:49

1、下载

https://github.com/oclint/oclint/releases

2、规则

http://docs.oclint.org/en/stable/rules/index.html

3、使用说明:

http://docs.oclint.org/en/stable/

4、安装xcpretty

gem install xcpretty

5、配置环境变量

OCLINT_HOME=/Users/XX/iOSTools/oclint-0.10.2
export PATH=$OCLINT_HOME/bin:$PATH

6、执行静态代码检查

1)cd 进入项目,执行以下命令:
xcodebuild -workspace OneScar.xcworkspace -scheme OneScar clean build | tee xcodebuild.log | xcpretty --report json-compilation-database
执行成功之后会在/build/reports下产生一个compilation_db.json文件
2)mv build/reports/compilation_db.json  compile_commands.json
将compilation_db.json文件 拷贝到ONESCar文件夹下
3)生成报告 report.html
oclint-json-compilation-database -v -- -report-type html -o report.html -max-priority-1=99999 -max-priority-2=99999 -max-priority-3=99999

7、报告展现形式:


8、如何修改规则:

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

9、具体规则分析:
10、优缺点:

优:规则比较多
缺点:
检查出的报告不能定位到代码。
0 0