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

Parenthesis in trailing closure rule #885

Closed
marcelofabri opened this issue Nov 20, 2016 · 1 comment
Closed

Parenthesis in trailing closure rule #885

marcelofabri opened this issue Nov 20, 2016 · 1 comment
Labels
rule-request Requests for a new rules.

Comments

@marcelofabri
Copy link
Collaborator

When using trailing closures, one can add () after the method call, but that should be discouraged.

let x = [1, 2]

// shouldn't trigger
_ = x.map { $0 + 1 }

// should trigger
_ = x.map() { $0 + 1 }

Note that there are cases when parenthesis are allowed (when there're more than 1 parameter):

// shouldn't trigger
_ = x.reduce(0) { $0 + $1 }
@jpsim
Copy link
Collaborator

jpsim commented Nov 25, 2016

EmptyParenthesesWithTrailingClosureRule. A bit verbose, but descriptive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule-request Requests for a new rules.
Projects
None yet
Development

No branches or pull requests

3 participants
@jpsim @marcelofabri and others