mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
With the binding of configurations to their associated rule types "unknown configuration" errors can be made more specific mentioning also the rule's identifier in the printed message.
31 lines
1.3 KiB
Swift
31 lines
1.3 KiB
Swift
struct OperatorUsageWhitespaceConfiguration: SeverityBasedRuleConfiguration, Equatable {
|
|
typealias Parent = OperatorUsageWhitespaceRule
|
|
|
|
private(set) var severityConfiguration = SeverityConfiguration<Parent>(.warning)
|
|
private(set) var linesLookAround = 2
|
|
private(set) var skipAlignedConstants = true
|
|
private(set) var allowedNoSpaceOperators: [String] = ["...", "..<"]
|
|
|
|
var consoleDescription: String {
|
|
return "severity: \(severityConfiguration.consoleDescription)"
|
|
+ ", lines_look_around: \(linesLookAround)"
|
|
+ ", skip_aligned_constants: \(skipAlignedConstants)"
|
|
+ ", allowed_no_space_operators: \(allowedNoSpaceOperators)"
|
|
}
|
|
|
|
mutating func apply(configuration: Any) throws {
|
|
guard let configuration = configuration as? [String: Any] else {
|
|
throw Issue.unknownConfiguration(ruleID: Parent.identifier)
|
|
}
|
|
|
|
linesLookAround = configuration["lines_look_around"] as? Int ?? 2
|
|
skipAlignedConstants = configuration["skip_aligned_constants"] as? Bool ?? true
|
|
allowedNoSpaceOperators =
|
|
configuration["allowed_no_space_operators"] as? [String] ?? ["...", "..<"]
|
|
|
|
if let severityString = configuration["severity"] as? String {
|
|
try severityConfiguration.apply(configuration: severityString)
|
|
}
|
|
}
|
|
}
|