Skip to content

Commit 62123de

Browse files
committed
Check for file just once
1 parent 9fc7adf commit 62123de

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Source/SwiftLintFramework/Extensions/FileManager+SwiftLint.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public enum Excluder {
4545
}
4646
}
4747

48-
extension FileManager: LintableFileManager {
48+
extension FileManager: LintableFileManager, @unchecked @retroactive Sendable {
4949
public func filesToLint(inPath path: String,
5050
rootDirectory: String? = nil,
5151
excluder: Excluder) -> [String] {
@@ -81,19 +81,21 @@ extension FileManager: LintableFileManager {
8181
while let element = enumerator.nextObject() as? String {
8282
let absoluteElementPath = URL(fileURLWithPath: element, relativeTo: absolutePath)
8383
let absoluteStandardizedElementPath = absoluteElementPath.standardized.filepath
84-
85-
if enumerator.fileAttributes?[.type] as? FileAttributeType == .typeDirectory {
84+
if absoluteElementPath.path.isFile {
85+
if absoluteElementPath.pathExtension == "swift",
86+
!excluder.excludes(path: absoluteStandardizedElementPath) {
87+
files.append(absoluteStandardizedElementPath)
88+
}
89+
} else {
8690
enumerator.skipDescendants()
8791
if !excluder.excludes(path: absoluteStandardizedElementPath) {
8892
directoriesToWalk.append(absoluteStandardizedElementPath)
8993
}
90-
} else if absoluteElementPath.isSwiftFile, !excluder.excludes(path: absoluteStandardizedElementPath) {
91-
files.append(absoluteStandardizedElementPath)
9294
}
9395
}
9496

9597
return files + directoriesToWalk.parallelFlatMap {
96-
FileManager().collectFiles(atPath: URL(fileURLWithPath: $0), excluder: excluder)
98+
collectFiles(atPath: URL(fileURLWithPath: $0), excluder: excluder)
9799
}
98100
}
99101

0 commit comments

Comments
 (0)