-
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
SwiftLint doesn't find a nested configuration when one specific file is specified #3341
Comments
I was incorrect about my hypothesized root cause in the initial description. There were two problems that needed fixing here:
I've got a fix for this in place, just need to clean it up. Will update #3342 when it's ready |
I was mistaken; this actually isn't SwiftLint's intended behavior. This is stated clearly in the README, I just missed it. So (2) above doesn't need to be done, we just need to fix (1). Updating the PR now. |
Fixes #3341 When SwiftLint searches for nested configurations and only one file has been passed in via the `paths` argument, SwiftLint returns early after inadvertently comparing the containing directory of the file-to-be-linted to itself. This happens because `rootDirectory` is calculated from `rootPath`, which is set to the file being linted in this scenario.
@jpsim Feels like we should open this one back up since the change had to be reverted. I don't seem to have permissions to do that if you wouldn't mind! |
This was previously attempted in #3342, but produced a bug in the case where `--config` is used to specify a config from outside of the source tree. The `--config` argument wasn't always being used as an override, and was being merged with the config in the source tree. This has now been addressed and reverts the revert done in #3362. Fixes #3341
New Issue Checklist
Describe the bug
Assume a file exists called
Path/To/My/File.swift
, and assumePath/To/My
is a directory that contains a.swiftlint.yml
file. When you tell SwiftLint to lint only the file, it uses the default configuration instead of the YAML file inPath/To/My
.I believe the root cause is due to these lines, which return the default configuration immediately instead of checking the directory for any configurations.
Complete output when running SwiftLint, including the stack trace and command used
Environment
swiftlint version
to be sure)? 0.40.2Yes, see above.
xcodebuild -version
)?Xcode 11.7
Build version 11E801a
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
.See above.
The text was updated successfully, but these errors were encountered: