Skip to content

Revert "Fix finding the nested config when a single file path is passed"#3362

Merged
jpsim merged 1 commit into
masterfrom
revert-3342-fixSingleFileNestedConfig
Sep 22, 2020
Merged

Revert "Fix finding the nested config when a single file path is passed"#3362
jpsim merged 1 commit into
masterfrom
revert-3342-fixSingleFileNestedConfig

Conversation

@jpsim

@jpsim jpsim commented Sep 22, 2020

Copy link
Copy Markdown
Collaborator

Reverts #3342

This caused a regression in one of my projects. cc @sethfri

It's a closed source project so it'll take some time for me to craft a repro case.

@jpsim jpsim merged commit a67b0f2 into master Sep 22, 2020
@jpsim jpsim deleted the revert-3342-fixSingleFileNestedConfig branch September 22, 2020 15:30
@SwiftLintBot

Copy link
Copy Markdown
12 Messages
📖 Linting Aerial with this PR took 1.9s vs 1.84s on master (3% slower)
📖 Linting Alamofire with this PR took 2.69s vs 2.7s on master (0% faster)
📖 Linting Firefox with this PR took 9.35s vs 9.17s on master (1% slower)
📖 Linting Kickstarter with this PR took 15.33s vs 15.18s on master (0% slower)
📖 Linting Moya with this PR took 1.3s vs 1.33s on master (2% faster)
📖 Linting Nimble with this PR took 1.34s vs 1.36s on master (1% faster)
📖 Linting Quick with this PR took 0.63s vs 0.62s on master (1% slower)
📖 Linting Realm with this PR took 2.67s vs 2.68s on master (0% faster)
📖 Linting SourceKitten with this PR took 1.02s vs 1.01s on master (0% slower)
📖 Linting Sourcery with this PR took 7.12s vs 7.17s on master (0% faster)
📖 Linting Swift with this PR took 10.93s vs 10.88s on master (0% slower)
📖 Linting WordPress with this PR took 17.07s vs 16.9s on master (1% slower)

Generated by 🚫 Danger

@sethfri

sethfri commented Sep 25, 2020

Copy link
Copy Markdown
Contributor

@jpsim Interesting! Thanks for the tag. Lmk once you're able to get a repro case together; I'd be more than happy to take another stab at a fix!

@jpsim

jpsim commented Sep 25, 2020

Copy link
Copy Markdown
Collaborator Author

Yeah, sorry for the lack of details yet. I have to reduce what we're doing to something I can share here.

@jpsim

jpsim commented Sep 25, 2020

Copy link
Copy Markdown
Collaborator Author

It has something to do with specifying an out-of-tree config file while linting a directory that already has a .swiftlint.yml file at its root.

@sethfri

sethfri commented Sep 25, 2020

Copy link
Copy Markdown
Contributor

@jpsim That's helpful, thanks! Is the behavior you're seeing that the passed in file is ignored in favor of the root .swiftlint.yml?

@jpsim

jpsim commented Sep 25, 2020

Copy link
Copy Markdown
Collaborator Author

I think so.

@sethfri

sethfri commented Sep 25, 2020

Copy link
Copy Markdown
Contributor

What is the expected behavior in that scenario @jpsim? Should the root file be completely ignored in favor of the passed in file, or would we expect them to be merged?

@jpsim

jpsim commented Sep 25, 2020

Copy link
Copy Markdown
Collaborator Author

Hmmm, good question. I can see arguments for either way. In almost every other case we merge configurations with parents.

@sethfri

sethfri commented Sep 25, 2020

Copy link
Copy Markdown
Contributor

@jpsim Personally I would expect the config argument to be treated as an override. "Ignore what I have, just test my project out with this config". You mentioned that there was a regression here though, so I wanted to check what the expected behavior was for your project

@jpsim

jpsim commented Sep 25, 2020

Copy link
Copy Markdown
Collaborator Author

Yes, for an explicit config passed as an argument, I'd also expect that to take precedence.

optionalendeavors added a commit to optionalendeavors/SwiftLint that referenced this pull request Oct 4, 2020
* master-upstream: (98 commits)
  Fix some false positives in rule `explicit_self` (realm#3368)
  Update SourceKitten to 0.30.1 (realm#3367)
  Fix issues with analyzer rules, Xcode 12 & SwiftUI (realm#3366)
  Add empty changelog section
  release 0.40.3
  Fix false positives for 'multiple_closures_with_trailing_closure' (realm#3353)
  [UnusedDeclarationRule] Work around SR-11985 (realm#3363)
  Revert "Fix finding the nested config when a single file path is passed (realm#3342)" (realm#3362)
  [CONTRIBUTING] Add building & running tips (realm#3360)
  Fix finding the nested config when a single file path is passed (realm#3342)
  Include Linux zip in list of GitHub release binaries (realm#3350)
  [UnusedDeclarationRule] Add more tests (realm#3359)
  Test CI with official Swift 5.3 release (realm#3356)
  Don't mark `@NSApplicationMain` or `@UIApplicationMain` classes as unused (realm#3355)
  [Fix] `UnusedCaptureListRule`: implicit self in @escaping closures (realm#3352)
  Skip correcting files with parser diagnostics (realm#3349)
  [SwiftLintFile] Remove lock in favor of UUID (realm#3347)
  [UnusedDeclarationRule] Speed up and detect more dead code (realm#3340)
  Add empty changelog section
  release 0.40.2
  ...

# Conflicts:
#	Source/swiftlint/Helpers/LintableFilesVisitor.swift
optionalendeavors added a commit to optionalendeavors/SwiftLint that referenced this pull request Oct 4, 2020
* master: (98 commits)
  Fix some false positives in rule `explicit_self` (realm#3368)
  Update SourceKitten to 0.30.1 (realm#3367)
  Fix issues with analyzer rules, Xcode 12 & SwiftUI (realm#3366)
  Add empty changelog section
  release 0.40.3
  Fix false positives for 'multiple_closures_with_trailing_closure' (realm#3353)
  [UnusedDeclarationRule] Work around SR-11985 (realm#3363)
  Revert "Fix finding the nested config when a single file path is passed (realm#3342)" (realm#3362)
  [CONTRIBUTING] Add building & running tips (realm#3360)
  Fix finding the nested config when a single file path is passed (realm#3342)
  Include Linux zip in list of GitHub release binaries (realm#3350)
  [UnusedDeclarationRule] Add more tests (realm#3359)
  Test CI with official Swift 5.3 release (realm#3356)
  Don't mark `@NSApplicationMain` or `@UIApplicationMain` classes as unused (realm#3355)
  [Fix] `UnusedCaptureListRule`: implicit self in @escaping closures (realm#3352)
  Skip correcting files with parser diagnostics (realm#3349)
  [SwiftLintFile] Remove lock in favor of UUID (realm#3347)
  [UnusedDeclarationRule] Speed up and detect more dead code (realm#3340)
  Add empty changelog section
  release 0.40.2
  ...
@sethfri

sethfri commented Oct 11, 2020

Copy link
Copy Markdown
Contributor

Just had time to set up a repro for this. Using the sample project (out-of-tree config not included in the zip):

  • Before my change: Out-of-tree config is used in place of the root config
  • After my change: Out-of-tree config is merged with root config

SwiftLintBugTest.zip

Will see if I can figure out how to fix this, but is this consistent with what you were seeing @jpsim?

sethfri added a commit to sethfri/SwiftLint that referenced this pull request Oct 11, 2020
@jpsim

jpsim commented Oct 11, 2020

Copy link
Copy Markdown
Collaborator Author

That sounds like what I was seeing, yes. Thanks for taking the time to do this!

@sethfri

sethfri commented Oct 11, 2020

Copy link
Copy Markdown
Contributor

@jpsim Np! Opened a PR with a fix in #3379

sethfri added a commit to sethfri/SwiftLint that referenced this pull request Oct 26, 2020
sethfri added a commit to sethfri/SwiftLint that referenced this pull request Oct 26, 2020
jpsim pushed a commit to sethfri/SwiftLint that referenced this pull request Nov 8, 2020
jpsim pushed a commit that referenced this pull request Nov 8, 2020
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
@sethfri sethfri mentioned this pull request Nov 9, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants