SwiftLint

作者: rajs20222007 | 来源:发表于2018-11-18 11:02 被阅读0次

官方文档: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

步骤摘要:

  1. 电脑brew安装swiftlint
  2. pod ‘swiftlint’(大小写)
  3. new run script:
if which swiftlint >/dev/null; then
  swiftlint
else
  echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
  1. 更多参考文档;

本机的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的检查方式、文件范围、规则

  1. 最简单的方式是直接禁用某个lint规则:
    比如 // swiftlint:disable line_length (可以写在某个函数顶部,也可以写在整个类的顶部)

  2. 在根目录创建
    .swiftlint.yml
    然后添加到刚刚的new run script里的input file里,那么这个规则就会被执行;

相关文章

网友评论

      本文标题:SwiftLint

      本文链接:https://www.haomeiwen.com/subject/udowfqtx.html