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: Unneeded parentheses in closure argument #1483

Closed
marcelofabri opened this Issue May 1, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@marcelofabri
Collaborator

marcelofabri commented May 1, 2017

// good
let foo = { (bar: Int) in
    print(bar)
}

// bad
call(arg: { (bar2) in

})

We could use a regex (\{\s*\([^:]+\)\s*in) to do it and also check for source.lang.swift.decl.var.parameter without a key.typename.

Stole the idea and regex from @keith

@marcelofabri

This comment has been minimized.

Show comment
Hide comment
@marcelofabri

marcelofabri May 1, 2017

Collaborator

Maybe this should have an option to allow the parentheses when the return type is explicit and there are more than one parameter? e.g.

ruleList.list.flatMap { (identifier, rule) -> [(String, String)] in
   return rule.description.deprecatedAliases.map { ($0, identifier) }
}
Collaborator

marcelofabri commented May 1, 2017

Maybe this should have an option to allow the parentheses when the return type is explicit and there are more than one parameter? e.g.

ruleList.list.flatMap { (identifier, rule) -> [(String, String)] in
   return rule.description.deprecatedAliases.map { ($0, identifier) }
}
@Dschee

This comment has been minimized.

Show comment
Hide comment
@Dschee

Dschee May 29, 2017

Contributor

Emphasis on "and", I'd say. See my examples in my request (#1583) to see what I mean what I'd expect to be accepted.

Contributor

Dschee commented May 29, 2017

Emphasis on "and", I'd say. See my examples in my request (#1583) to see what I mean what I'd expect to be accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment