Files
SwiftLint/Source/SwiftLintFramework/Extensions/Configuration+LintableFiles.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

27 lines
1.1 KiB
Swift

import Foundation
import SourceKittenFramework
extension Configuration {
public func lintableFiles(inPath path: String, forceExclude: Bool) -> [File] {
return lintablePaths(inPath: path, forceExclude: forceExclude).compactMap(File.init(pathDeferringReading:))
}
internal func lintablePaths(inPath path: String, forceExclude: Bool,
fileManager: LintableFileManager = FileManager.default) -> [String] {
// If path is a file and we're not forcing excludes, skip filtering with excluded/included paths
if path.isFile && !forceExclude {
return [path]
}
let pathsForPath = included.isEmpty ? fileManager.filesToLint(inPath: path, rootDirectory: nil) : []
let excludedPaths = excluded.flatMap {
fileManager.filesToLint(inPath: $0, rootDirectory: rootPath)
}
let includedPaths = included.flatMap {
fileManager.filesToLint(inPath: $0, rootDirectory: rootPath)
}
return (pathsForPath + includedPaths).filter {
!excludedPaths.contains($0)
}
}
}