mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
4266ea9d60
* Add Bool violation detection * Update Changelog * Fix issues found by the rule
27 lines
1000 B
Swift
27 lines
1000 B
Swift
private enum ConfigurationKey: String {
|
|
case severity = "severity"
|
|
case onlyAfterDot = "only_after_dot"
|
|
}
|
|
|
|
public struct EmptyCountConfiguration: RuleConfiguration, Equatable {
|
|
private(set) var severityConfiguration = SeverityConfiguration(.error)
|
|
private(set) var onlyAfterDot = false
|
|
|
|
public var consoleDescription: String {
|
|
return [severityConfiguration.consoleDescription,
|
|
"\(ConfigurationKey.onlyAfterDot.rawValue): \(onlyAfterDot)"].joined(separator: ", ")
|
|
}
|
|
|
|
public mutating func apply(configuration: Any) throws {
|
|
guard let configuration = configuration as? [String: Any] else {
|
|
throw ConfigurationError.unknownConfiguration
|
|
}
|
|
|
|
if let severityString = configuration[ConfigurationKey.severity.rawValue] as? String {
|
|
try severityConfiguration.apply(configuration: severityString)
|
|
}
|
|
|
|
onlyAfterDot = configuration[ConfigurationKey.onlyAfterDot.rawValue] as? Bool ?? false
|
|
}
|
|
}
|