首页 > 解决方案 > SwiftLint 突然停止忽略我的 Pods 文件夹并且它给出了错误

问题描述

我正在一个巨大的快速项目中工作。我正在从 cocoapods 测试 DeviceKit pod,并且直到今天都运行良好。即使是昨天也完美无缺。

现在,突然我无法编译,因为那个类给了我这些错误:

Device.generated.swift:49:8:类型正文长度违规:类型正文应跨越 300 行或更少,不包括注释和空格:当前跨越 447 行(type_body_length)

Device.generated.swift:220:10:标识符名称违规:枚举元素名称应仅包含字母数字字符:'appleWatchSeries0_42mm'(标识符名称)

Device.generated.swift:1150:1:文件行长度违规:文件应包含 400 行或更少:当前包含 1150 (file_length)

这是这个项目中的这个类: https ://github.com/devicekit/DeviceKit/blob/master/Source/Device.generated.swift

我没有碰过这个类,它是一个pod里面的一个类,所以我不明白为什么昨天它编译得很好,现在它没有编译。这怎么可能?

SwiftLint我的cocoapods pod 文件中有这个版本:

pod 'SwiftLint', '<= 0.20.1' # SwiftLint, para limpieza de código

我尝试将其更新到最新版本,但问题仍然存在。

这是我的.SwiftLint.yml文件,如您所见,它忽略了 pod:

disabled_rules: # rule identifiers to exclude from running
#  - colon
#  - comma
  - control_statement
  - vertical_whitespace
  - trailing_whitespace
  - discarded_notification_center_observer
opt_in_rules: # some rules are only opt-in
  - explicit_init
  - fatal_error_message
  - first_where
  - multiline_parameters
  - operator_usage_whitespace
  - private_outlet
  - cyclomatic_complexity
included: # paths to include during linting. `--path` is ignored if present.
excluded: # paths to ignore during linting. Takes precedence over `included`.
  - Pods

# configurable rules can be customized from this configuration file
# binary rules can set their severity level
force_cast: warning # implicitly
force_try:
  severity: warning # explicitly
# rules that have both warning and error levels, can set just the warning level
# implicitly
function_body_length:
  warning: 50
  error: 200
line_length: 
  warning: 200
  error: 300
  ignores_function_declarations: true
  ignores_comments: true
identifier_name:
  min_length:
    warning: 3
  excluded:
    - id
    - to
    - db
    - ad
# they can set both implicitly with an array
type_body_length:
  - 300 # warning
  - 400 # error
# or they can set both explicitly
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji)

标签: iosswiftxcodecocoapodsswiftlint

解决方案


推荐阅读