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

False positive in unused_closure_parameter #1979

Closed
2 tasks done
jpsim opened this issue Dec 21, 2017 · 3 comments
Closed
2 tasks done

False positive in unused_closure_parameter #1979

jpsim opened this issue Dec 21, 2017 · 3 comments
Labels

Comments

@jpsim
Copy link
Collaborator

jpsim commented Dec 21, 2017

New Issue Checklist

Bug Report

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint --path test.swift
Linting Swift files at path test.swift
Linting 'test.swift' (1/1)
/Users/jsimard/Downloads/test.swift:3:5: warning: Unused Closure Parameter Violation: Unused parameter "manager" in a closure should be replaced with _. (unused_closure_parameter)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

  • SwiftLint version (run swiftlint version to be sure)?

0.24.0

  • Installation method used (Homebrew, CocoaPods, building from source, etc)?

Homebrew

  • Paste your configuration file:

None.

None.

  • Which Xcode version are you using (check xcode-select -p)?

/Applications/Xcode-9.2.app/Contents/Developer

  • Do you have a sample that shows the issue? Run 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.
import Foundation

({ (manager: FileManager) in
  print(manager)
})(FileManager.default)

Also, as reported by @irace:

image

@jpsim jpsim added the bug label Dec 21, 2017
@irace
Copy link

irace commented Dec 21, 2017 via email

@jpsim
Copy link
Collaborator Author

jpsim commented Dec 21, 2017

So SourceKit is returning some BS with closures of this format. Here's what it thinks the name of the closure is: ({ (manager: FileManager) in\n print(manager)\n}), and the body is (FileManager.default).

Looking into making a workaround.

@marcelofabri
Copy link
Collaborator

This would be way easier/more reliable if we SourceKit returned closures in the structure (https://bugs.swift.org/browse/SR-6116). I started implementing it a few months ago, but it looks like I lost my WIP branch ¯_(ツ)_/¯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants