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 false positives for 'multiple_closures_with_trailing_closure' #3353

Merged
merged 1 commit into from
Sep 22, 2020

Conversation

Jumhyn
Copy link
Contributor

@Jumhyn Jumhyn commented Sep 18, 2020

Resolves #3295

@SwiftLintBot
Copy link

1 Warning
⚠️ This PR may need tests.
12 Messages
📖 Linting Aerial with this PR took 0.85s vs 0.79s on master (7% slower)
📖 Linting Alamofire with this PR took 1.01s vs 0.99s on master (2% slower)
📖 Linting Firefox with this PR took 3.86s vs 3.77s on master (2% slower)
📖 Linting Kickstarter with this PR took 6.43s vs 6.22s on master (3% slower)
📖 Linting Moya with this PR took 0.5s vs 0.52s on master (3% faster)
📖 Linting Nimble with this PR took 0.58s vs 0.57s on master (1% slower)
📖 Linting Quick with this PR took 0.33s vs 0.32s on master (3% slower)
📖 Linting Realm with this PR took 1.12s vs 1.18s on master (5% faster)
📖 Linting SourceKitten with this PR took 0.48s vs 0.5s on master (4% faster)
📖 Linting Sourcery with this PR took 2.6s vs 2.56s on master (1% slower)
📖 Linting Swift with this PR took 8.24s vs 8.23s on master (0% slower)
📖 Linting WordPress with this PR took 7.09s vs 7.05s on master (0% slower)

Generated by 🚫 Danger

@codecov-commenter
Copy link

codecov-commenter commented Sep 18, 2020

Codecov Report

Merging #3353 into master will decrease coverage by 0.00%.
The diff coverage is 95.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3353      +/-   ##
==========================================
- Coverage   90.52%   90.52%   -0.01%     
==========================================
  Files         417      417              
  Lines       20434    20471      +37     
==========================================
+ Hits        18498    18531      +33     
- Misses       1936     1940       +4     
Impacted Files Coverage Δ
...tyle/MultipleClosuresWithTrailingClosureRule.swift 85.52% <95.91%> (+8.60%) ⬆️
...rce/SwiftLintFramework/Rules/Style/CommaRule.swift 95.65% <0.00%> (-4.35%) ⬇️
...iftLintFramework/Extensions/String+SwiftLint.swift 94.54% <0.00%> (-1.82%) ⬇️
...ftLintFramework/Rules/Lint/PrivateOutletRule.swift 100.00% <0.00%> (+3.84%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e537fa...844f896. Read the comment docs.

@Jumhyn
Copy link
Contributor Author

Jumhyn commented Sep 20, 2020

This is likely a good candidate to be written in SwiftSyntax—what’s the current support status for that? I see an old PR got merged, reverted, and then re-opened, but it looks like that last PR has gone stale...

@Jumhyn
Copy link
Contributor Author

Jumhyn commented Sep 22, 2020

@jpsim Is there further work this needs to be mergeable?

@jpsim
Copy link
Collaborator

jpsim commented Sep 22, 2020

This is likely a good candidate to be written in SwiftSyntax—what’s the current support status for that? I see an old PR got merged, reverted, and then re-opened, but it looks like that last PR has gone stale...

SwiftSyntax needs to be properly linked to handle the issues discussed in #3105 before we can use it in a release.

@jpsim
Copy link
Collaborator

jpsim commented Sep 22, 2020

Thanks for the PR!

I suspect there are ways to improve this to avoid using regular expressions, but given this is giving false positives on Swift 5.3, I'll merge this now.

@jpsim jpsim merged commit 64b309e into realm:master Sep 22, 2020
@Jumhyn
Copy link
Contributor Author

Jumhyn commented Sep 22, 2020

@jpsim Yeah I'm not thrilled with the implementation, but I couldn't come up with a great alternative off the top of my head given the info available in a SourceKittenDictionary (the old heuristic of "if the argument ends at the same location as the call itself, it's a trailing closure" is clearly no longer valid). This was my first time actually digging into the source of SwiftLint, though, so it's very likely I've overlooked something. If you have a suggestion about any directions to pursue I'd be more than happy to investigate!

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
  ...
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.

"Multiple Closures With Trailing Closure" support for multiple trailing closures (Swift 5.3)
4 participants