【问题标题】:How to disable the character limit in swiftlint config file如何在 swiftlint 配置文件中禁用字符限制
【发布时间】:2019-05-27 13:55:45
【问题描述】:

我正在做一个项目,我需要如何在 swiftlint 配置文件中禁用字符限制,那么如何禁用字符限制??

这里是 swiftlint 文件

disabled_rules:
  - force_cast
  - force_try
  - variable_name
  - type_name
  - file_length
  - type_body_length
  - cyclomatic_complexity
  - function_body_length
  - valid_docs
  - trailing_whitespace

opt_in_rules:
  - empty_string

excluded:
  - Carthage
  - Pods
  - SwiftLint/Common/3rdPartyLib

line_length:
    warning: 150
    error: 200
    ignores_function_declarations: true
    ignores_comments: true
    ignores_urls: true

custom_rules:
  smiley_face:
    name: "Smiley Face"
    regex: '( :\))'
    match_kinds:
      - comment
      - string
    message: "A closing parenthesis smiley :) creates a half-hearted smile, and thus is not preferred. Use :]"
severity: warning

【问题讨论】:

  • file_length 已添加,应该可以使用,需要什么字符限制?
  • 实际上是行字符限制,我需要禁用它,因为它表明该行应该是 150 个字符或更少
  • 你不能把它增加到一个非常高的限制吗?
  • 没有我的维护人员要求我禁用行字符限制。
  • 那么您在下面有一个答案,那么问题是什么?

标签: ios swift swiftlint


【解决方案1】:

如果您遇到此警告的问题:

Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'by' (identifier_name) 

您可以将这些命令添加到您的配置文件中:

variable_name:   
max_length:
    warning: 45
    error: 60   
min_length:
    warning: 1

我希望这对您有所帮助并符合您的问题。

【讨论】:

    【解决方案2】:

    我想你可以在disabled_rules 中添加line_length,如果这就是你的意思的话。

    【讨论】:

    • 是的,我需要禁用行字符限制
    • 所以,正如我所说,您只需删除当前与line_length 相关的所有内容,然后在disabled_rules 中添加- line_length
    猜你喜欢
    • 2021-09-29
    • 1970-01-01
    • 2020-07-04
    • 1970-01-01
    • 2013-02-27
    • 1970-01-01
    • 1970-01-01
    • 2011-12-29
    • 2021-01-21
    相关资源
    最近更新 更多