gpt4 book ai didi

iOS SwiftLint 标识符名称不起作用

转载 作者:行者123 更新时间:2023-12-05 05:56:54 24 4
gpt4 key购买 nike

https://realm.github.io/SwiftLint/identifier_name.html

你好。我最近遇到了 swiftlin 并了解了这一点。但是有一个问题。我修改了 swiftlint 的标识符名称以保持 CalmelCase 语法,但它没有用。

这是我的 .swiftlint.yml 文本。

identifier_name:
allowed_symbols: ["_"]
validates_start_with_lowercase: false
min_length:
warning: 1

disabled_rules: # rule identifiers to exclude from running
- colon
- comma
- control_statement

opt_in_rules: # some rules are only opt-in
- empty_count
- missing_docs
# Find all the available rules by running:
# swiftlint rules

included: # paths to include during linting. `--path` is ignored if present.
- Source

excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- Source/ExcludedFolder
- Source/ExcludedFile.swift

enter image description here

import UIKit

class timeVC: UIViewController {

@IBOutlet weak var timePicker: UIDatePicker!

override func viewDidLoad() {
super.viewDidLoad()

}

@IBAction func clickDone(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
}

enter image description here

无论“validates_start_with_lowercase”是真还是假,错误仍然存​​在。我犯了什么错误?

最佳答案

您已更改标识符规则,但触发的规则是针对 type names 的.

类型名称应以大写字母开头。

将您的类(class)名称更改为 TimeVC

import UIKit

class TimeVC: UIViewController {

@IBOutlet weak var timePicker: UIDatePicker!

override func viewDidLoad() {
super.viewDidLoad()

}

@IBAction func clickDone(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
}

您也不应更改 identifier_name 规则。如果您打算违反 Swift 风格的这种基本元素,那么即使使用 linter 也可能没有多大意义。

关于iOS SwiftLint 标识符名称不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68960649/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com