-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathFileNameConfiguration.swift
More file actions
32 lines (30 loc) · 1.21 KB
/
FileNameConfiguration.swift
File metadata and controls
32 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Foundation
import SourceKittenFramework
import SwiftLintCore
@AutoConfigParser
struct FileNameConfiguration: SeverityBasedRuleConfiguration {
@ConfigurationElement(key: "severity")
private(set) var severityConfiguration = SeverityConfiguration<Parent>(.warning)
@ConfigurationElement(key: "excluded")
private(set) var excluded = Set(["main.swift", "LinuxMain.swift"])
@ConfigurationElement(key: "excluded_paths")
private(set) var excludedPaths = Set<RegularExpression>()
@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 = "."
@ConfigurationElement(key: "require_fully_qualified_names")
private(set) var requireFullyQualifiedNames = false
}
extension FileNameConfiguration {
func shouldExclude(filePath: URL) -> Bool {
if excluded.contains(filePath.lastPathComponent) {
return true
}
return excludedPaths.contains {
$0.regex.firstMatch(in: filePath.path, range: filePath.path.fullNSRange) != nil
}
}
}