Skip to content
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

Fix bug where nested configuration excluded files are ignored #2648

Merged
merged 5 commits into from
Apr 7, 2019

Conversation

Bruschidy54
Copy link
Contributor

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.

Copy link
Contributor Author

@Bruschidy54 Bruschidy54 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcelofabri @Dschee I'd appreciate some feedback when you get the chance :)

Copy link
Collaborator

@Jeehut Jeehut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made some comments, please review them. Apart from that, I hope @marcelofabri or @jpsim can jump in here regarding if this is ok to merge since I have no experience at all with multiple configuration files yet.

CHANGELOG.md Outdated Show resolved Hide resolved
@SwiftLintBot
Copy link

12 Messages
📖 Linting Aerial with this PR took 1.84s vs 1.78s on master (3% slower)
📖 Linting Alamofire with this PR took 3.84s vs 3.86s on master (0% faster)
📖 Linting Firefox with this PR took 12.53s vs 12.18s on master (2% slower)
📖 Linting Kickstarter with this PR took 20.03s vs 19.87s on master (0% slower)
📖 Linting Moya with this PR took 1.88s vs 1.85s on master (1% slower)
📖 Linting Nimble with this PR took 1.71s vs 1.71s on master (0% slower)
📖 Linting Quick with this PR took 0.59s vs 0.55s on master (7% slower)
📖 Linting Realm with this PR took 3.3s vs 3.3s on master (0% slower)
📖 Linting SourceKitten with this PR took 1.11s vs 1.11s on master (0% slower)
📖 Linting Sourcery with this PR took 3.96s vs 4.15s on master (4% faster)
📖 Linting Swift with this PR took 25.89s vs 26.28s on master (1% faster)
📖 Linting WordPress with this PR took 21.07s vs 21.15s on master (0% faster)

Generated by 🚫 Danger

@Jeehut
Copy link
Collaborator

Jeehut commented Mar 7, 2019

Thanks for updating the code. I have one more question: Do you think you could add tests to prevent this change from breaking again in the future?

@jpsim
Copy link
Collaborator

jpsim commented Apr 7, 2019

Thanks for the PR @Bruschidy54!

Do you think you could add tests to prevent this change from breaking again in the future?

Tests would be great, although we don't currently have the ability to run unit tests against the swiftlint target, only SwiftLintFramework. I don't 100% recall why I set things up this way, but my initial intention was for the swiftlint target to be as small as possible, really just a shim around SwiftLintFramework. Evidently it grew over time to be much more than a shim.

@Bruschidy54
Copy link
Contributor Author

@Dschee @jpsim Is it possible to accept the PR without SwiftLintFramework tests for now? Work is really busy at the moment, so I won't have time to look at this in the near future.

@jpsim
Copy link
Collaborator

jpsim commented Apr 7, 2019

Yes, should be fine. I have some small followups that I'll do in a separate PR to avoid force-pushing to your fork's master branch.

Thanks for the fix @Bruschidy54 and for your code review @Dschee!

@jpsim
Copy link
Collaborator

jpsim commented Apr 7, 2019

Small followups here: #2707

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.

4 participants