Files
SwiftLint/Source/SwiftLintFramework/Rules/RuleConfigurations/ObjectLiteralConfiguration.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

34 lines
1.2 KiB
Swift

import Foundation
public struct ObjectLiteralConfiguration: RuleConfiguration, Equatable {
private(set) var severityConfiguration = SeverityConfiguration(.warning)
private(set) var imageLiteral = true
private(set) var colorLiteral = true
public var consoleDescription: String {
return severityConfiguration.consoleDescription
+ ", image_literal: \(imageLiteral)"
+ ", color_literal: \(colorLiteral)"
}
public mutating func apply(configuration: Any) throws {
guard let configuration = configuration as? [String: Any] else {
throw ConfigurationError.unknownConfiguration
}
imageLiteral = configuration["image_literal"] as? Bool ?? true
colorLiteral = configuration["color_literal"] as? Bool ?? true
if let severityString = configuration["severity"] as? String {
try severityConfiguration.apply(configuration: severityString)
}
}
public static func == (lhs: ObjectLiteralConfiguration,
rhs: ObjectLiteralConfiguration) -> Bool {
return lhs.severityConfiguration == rhs.severityConfiguration &&
lhs.imageLiteral == rhs.imageLiteral &&
lhs.colorLiteral == rhs.colorLiteral
}
}