Files
SwiftLint/Source/SwiftLintFramework/Rules/RuleConfigurations/ComputedAccessorsOrderRuleConfiguration.swift
T
JP SimardandGitHub 4bd7da32ea Reduce visibility of rules to be internal (#4533)
There's no reason to expose these publicly and this will make it nicer
to move to a new module outside of the core SwiftLint functionality.
2022-11-09 11:01:26 -05:00

29 lines
982 B
Swift

struct ComputedAccessorsOrderRuleConfiguration: SeverityBasedRuleConfiguration, Equatable {
enum Order: String {
case getSet = "get_set"
case setGet = "set_get"
}
private(set) var severityConfiguration = SeverityConfiguration(.warning)
private(set) var order = Order.getSet
var consoleDescription: String {
return [severityConfiguration.consoleDescription, "order: \(order.rawValue)"].joined(separator: ", ")
}
mutating func apply(configuration: Any) throws {
guard let configuration = configuration as? [String: Any] else {
throw ConfigurationError.unknownConfiguration
}
if let orderString = configuration["order"] as? String,
let order = Order(rawValue: orderString) {
self.order = order
}
if let severityString = configuration["severity"] as? String {
try severityConfiguration.apply(configuration: severityString)
}
}
}