官方文档:https://github.com/realm/SwiftLint
引用文档:http://www.cocoachina.com/ios/20170602/19415.html?utm_source=debugrun&utm_medium=referral
https://www.jianshu.com/p/d8fef88b26de
步骤摘要:
- 电脑brew安装swiftlint
- pod ‘swiftlint’(大小写)
- new run script:
if which swiftlint >/dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
- 更多参考文档;
本机的swiftlint help可以看到用命令行 分析代码
swiftlint help
Available commands:
autocorrect Automatically correct warnings and errors
generate-docs Generates markdown documentation for all rules
help Display general or command-specific help
lint Print lint warnings and errors (default command)
rules Display the list of rules and their identifiers
version Display the current version of SwiftLint
swiftlint autocorrect 自动纠错多余空格问题
配置swiftlint的检查方式、文件范围、规则
-
最简单的方式是直接禁用某个lint规则:
比如 // swiftlint:disable line_length (可以写在某个函数顶部,也可以写在整个类的顶部) -
在根目录创建
.swiftlint.yml
然后添加到刚刚的new run script里的input file里,那么这个规则就会被执行;
网友评论