OCLint

获取源代码

准备工作

  1. LLVM System Requirements
  2. Python
  3. Git
  4. Apache Subversion
  5. CMake
  6. OpenSSL
  7. Ninjia

参考步骤 https://oclint-docs.readthedocs.io/en/stable/intro/build.html

获取源代码

获取全新代码

git clone https://github.com/oclint/oclint.git
cd oclint
git clone https://github.com/oclint/oclint-json-compilation-database.git
git clone https://github.com/oclint/oclint-xcodebuild.git
cd oclint-scripts
./clang checkout
./countly checkout
./googleTest checkout
cd .. # back to the root folder of OCLint codebase

更新已有代码

cd oclint # start from OCLint root directory
git pull origin master
cd oclint-json-compilation-database
git pull origin master
cd ../oclint-xcodebuild
git pull origin master
cd ../oclint-scripts
./clang update
./googleTest update
cd .. # back to OCLint root directory

参考步骤 https://oclint-docs.readthedocs.io/en/stable/devel/checkout.html

编译

  1. cd oclint-scripts
  2. ./make
  3. cd ..

验证

./build/oclint-release/bin/oclint

如果有以下输出,则表示输出成功

oclint: Not enough positional command line arguments specified!
Must specify at least 1 positional argument: See: ./build/oclint-release/bin/oclint -help

Test

cd oclint/oclint-scripts
./countly build
./googleTest co
./googleTest build
./test

全部跑完一次后,下次可以只跑对应的模块

./test rules

更多参考https://oclint-docs.readthedocs.io/en/stable/devel/compiletest.html

打包oclint

测试通过后就可以打包oclint了,oclint/build/oclint-release含有最终生成的各种文件。
如果在本地使用,可以直接加到环境变量使用, 其中src-path是oclint源码所在的父目录

OCLINT_HOME=/src-path/oclint/build/oclint-release
export PATH=$OCLINT_HOME/bin:$PATH

打包到远程使用


使用oclint

xcodebuild -workspace $myworkspace -scheme $myscheme clean

xcodebuild -workspace $myworkspace -scheme $myscheme -configuration $configuration \
| xcpretty -r json-compilation-database -o compile_commands.json && \
oclint-json-compilation-database -e Pods -- \
-report-type html -o oclint_result.html \
-rc LONG_LINE=200 \
-max-priority-1=100000 \
-max-priority-2=100000 \
-max-priority-3=100000

自定义rule

参考 http://oriochan.com/codeReview01.html

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容