mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
39 lines
1.5 KiB
Swift
39 lines
1.5 KiB
Swift
import SwiftLintCore
|
|
|
|
struct FileNameConfiguration: SeverityBasedRuleConfiguration, Equatable {
|
|
typealias Parent = FileNameRule
|
|
|
|
@ConfigurationElement
|
|
private(set) var severityConfiguration = SeverityConfiguration<Parent>(.warning)
|
|
@ConfigurationElement(key: "excluded")
|
|
private(set) var excluded = Set<String>(["main.swift", "LinuxMain.swift"])
|
|
@ConfigurationElement(key: "prefix_pattern")
|
|
private(set) var prefixPattern = ""
|
|
@ConfigurationElement(key: "suffix_pattern")
|
|
private(set) var suffixPattern = "\\+.*"
|
|
@ConfigurationElement(key: "nested_type_separator")
|
|
private(set) var nestedTypeSeparator = "."
|
|
|
|
mutating func apply(configuration: Any) throws {
|
|
guard let configurationDict = configuration as? [String: Any] else {
|
|
throw Issue.unknownConfiguration(ruleID: Parent.identifier)
|
|
}
|
|
|
|
if let severity = configurationDict["severity"] {
|
|
try severityConfiguration.apply(configuration: severity)
|
|
}
|
|
if let excluded = [String].array(of: configurationDict["excluded"]) {
|
|
self.excluded = Set(excluded)
|
|
}
|
|
if let prefixPattern = configurationDict["prefix_pattern"] as? String {
|
|
self.prefixPattern = prefixPattern
|
|
}
|
|
if let suffixPattern = configurationDict["suffix_pattern"] as? String {
|
|
self.suffixPattern = suffixPattern
|
|
}
|
|
if let nestedTypeSeparator = configurationDict["nested_type_separator"] as? String {
|
|
self.nestedTypeSeparator = nestedTypeSeparator
|
|
}
|
|
}
|
|
}
|