Make forceExclude work with directly specified files (#4609)

This commit is contained in:
Jimmy Arts 2022-12-22 21:15:08 +01:00 committed by GitHub
parent d76daf5f62
commit eda0d92f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -13,7 +13,9 @@
#### Enhancements
* None.
* Make forceExclude work with directly specified files.
[jimmya](https://github.com/jimmya)
[#issue_number](https://github.com/realm/SwiftLint/issues/4609)
#### Bug Fixes

View File

@ -33,8 +33,15 @@ extension Configuration {
excludeByPrefix: Bool = false,
fileManager: LintableFileManager = FileManager.default
) -> [String] {
if path.isFile {
if forceExclude {
return excludeByPrefix
? filterExcludedPathsByPrefix(in: [path.absolutePathStandardized()])
: filterExcludedPaths(fileManager: fileManager, in: [path.absolutePathStandardized()])
}
// If path is a file and we're not forcing excludes, skip filtering with excluded/included paths
if path.isFile && !forceExclude { return [path] }
return [path]
}
let pathsForPath = includedPaths.isEmpty ? fileManager.filesToLint(inPath: path, rootDirectory: nil) : []
let includedPaths = self.includedPaths