Files
SwiftLint/Source/SwiftLintFramework/Rules/RuleConfigurations/VerticalWhitespaceConfiguration.swift
T
JP Simard b83e0991b9 Remove all file headers
The MIT license doesn't require that all files be prepended with this
licensing or copyright information. Realm confirmed that they're ok with this
change. This will enable some companies to contribute to SwiftLint and the
date & authorship information will remain accessible via git source control.
2018-05-04 13:42:02 -07:00

33 lines
1.2 KiB
Swift

public struct VerticalWhitespaceConfiguration: RuleConfiguration, Equatable {
private(set) var severityConfiguration = SeverityConfiguration(.warning)
private(set) var maxEmptyLines: Int
public var consoleDescription: String {
return severityConfiguration.consoleDescription + ", max_empty_lines: \(maxEmptyLines)"
}
public init(maxEmptyLines: Int) {
self.maxEmptyLines = maxEmptyLines
}
public mutating func apply(configuration: Any) throws {
guard let configuration = configuration as? [String: Any] else {
throw ConfigurationError.unknownConfiguration
}
if let maxEmptyLines = configuration["max_empty_lines"] as? Int {
self.maxEmptyLines = maxEmptyLines
}
if let severityString = configuration["severity"] as? String {
try severityConfiguration.apply(configuration: severityString)
}
}
public static func == (lhs: VerticalWhitespaceConfiguration,
rhs: VerticalWhitespaceConfiguration) -> Bool {
return lhs.maxEmptyLines == rhs.maxEmptyLines &&
lhs.severityConfiguration == rhs.severityConfiguration
}
}