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

Rule request: Enforce whether or not parentheses should be wrapped around closures #1176

Open
ghost opened this issue Jan 12, 2017 · 1 comment
Labels
rule-request Requests for a new rules.

Comments

@ghost
Copy link

ghost commented Jan 12, 2017

Currently closures can be written one of two ways:
myCollection.filter{ $0 == 1 }
or
myCollection.filter({ $0 == 1 })

These two different ways are identical and will run exactly the same way. Further more, this also extends to closures with multiple lines:

let newCollection = myCollection.map{ 
  2*$0 + 5
}

or

let newCollection = myCollection.map({ 
  2*$0 + 5
})

For this, I propose a new rule which allows the presence of parentheses to be required, or disallowed depending on the configuration. Furthermore, I think the rule should allow you to differentiate between inline closures and multi line closures. For instance, with a particular configuration this would be allowed:

myCollection.filter({ $0 == 1 })
let newCollection = myCollection.map {
    2*$0 + 5
}
@marcelofabri marcelofabri added the rule-request Requests for a new rules. label Jan 12, 2017
@marcelofabri
Copy link
Collaborator

Similar to #54

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

1 participant