mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
30 lines
1.2 KiB
Swift
30 lines
1.2 KiB
Swift
import SwiftLintCore
|
|
|
|
struct OperatorUsageWhitespaceConfiguration: SeverityBasedRuleConfiguration, Equatable {
|
|
typealias Parent = OperatorUsageWhitespaceRule
|
|
|
|
@ConfigurationElement(key: "severity")
|
|
private(set) var severityConfiguration = SeverityConfiguration<Parent>(.warning)
|
|
@ConfigurationElement(key: "lines_look_around")
|
|
private(set) var linesLookAround = 2
|
|
@ConfigurationElement(key: "skip_aligned_constants")
|
|
private(set) var skipAlignedConstants = true
|
|
@ConfigurationElement(key: "allowed_no_space_operators")
|
|
private(set) var allowedNoSpaceOperators = ["...", "..<"]
|
|
|
|
mutating func apply(configuration: Any) throws {
|
|
guard let configuration = configuration as? [String: Any] else {
|
|
throw Issue.unknownConfiguration(ruleID: Parent.identifier)
|
|
}
|
|
|
|
linesLookAround = configuration[$linesLookAround] as? Int ?? 2
|
|
skipAlignedConstants = configuration[$skipAlignedConstants] as? Bool ?? true
|
|
allowedNoSpaceOperators =
|
|
configuration[$allowedNoSpaceOperators] as? [String] ?? ["...", "..<"]
|
|
|
|
if let severityString = configuration[$severityConfiguration] as? String {
|
|
try severityConfiguration.apply(configuration: severityString)
|
|
}
|
|
}
|
|
}
|