-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Excluded paths in nested configurations are ignored #2447
Comments
+1 I believe I'm seeing a similar issue. |
I think I found a solution. When SwiftLint is linting files in visitLintableFiles in Configuration+CommandLine, it:
My solution is to skip files whose merged configurations specify they should be excluded in step 2 or groupFiles. Therefore, they will not be visited in step 3. Take a look at my PR :) |
Fixes #2447 When SwiftLint is linting files in `visitLintableFiles` in `Configuration+CommandLine`, it: 1. Gathers all lintable files in `getFiles`. This is where the exclusion of files occurs based on the parent configuration's exclusion list. 2. These files are grouped by their specific configuration in `groupFiles`. This is where configurations for each available file are determined (and if nested configurations exist, merged). After these configurations are determined and the files are grouped accordingly, no more files are excluded from the lintable files list. Even though a file's configuration thinks it should be excluded, these files are not removed from the list of lintable files, generating the bug. 3. Finally, each file is visited by the linter. My solution is to skip files whose merged configurations specify they should be excluded in step 2 or `groupFiles`. Therefore, they will not be visited in step 3.
New Issue Checklist
Describe the bug
My example project has this structure:
./swiftlint.yml
is empty,./A/swiftlint.yml
has the following contents:When I run
swiftlint
from the project's root directory,Longcat.swift
gets linted although it should be excluded.An explanation as to why I'm trying to do this: We have a common base
.swiftlint.yml
for our apps, which we symlink from a CocoaPod. Since we need to add project-specific excludes as well (and SwiftLint unfortunately doesn't seem to support shared base configurations at all), I need to mark individual folders as excluded from nested configurations.Complete output when running SwiftLint, including the stack trace and command used
Environment
swiftlint version
to be sure)?0.27.0
In this instance, I was using the
swiftlint
frombrew install swiftlint
See above.
If so, paste their relative paths and respective contents.
Yes. Toplevel is empty, nested config is the one shown above.
xcode-select -p
)?Version 10.0 (10A255)
echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
to quickly test if your example is really demonstrating the issue. If your example is more
complex, you can use
swiftlint lint --path [file here] --no-cache --enable-all-rules
.I've attached my minimal example project: swiftlint-nested-exclude-example.zip
The text was updated successfully, but these errors were encountered: