You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a rule request. I'm willing to implement this myself and send a PR, but before doing that I'd like to know if the rule is wanted or not. To explain the desired rule, I'd like to first post the custom rule we are already using in our projects:
closure_params_parantheses:
included: ".*.swift"regex: '\{\s*\([^):]+\)\s*in'name: "Unnecessary Closure Params Parantheses"message: "Don't use parantheses around non-typed parameters in a closure."severity: warning
I felt like this rule might be useful for other projects as well, which is why I'm posting it. What do you think about it? For us it helps a lot to prevent common issues and enforce a shared style.
Rationale
Xcode always includes parentheses around parameters in closures, even when they are not typed. In these cases they are not needed though and therefore should be omitted.
A few examples:
// ❌ not acceptable
doSomething{(key, value)in
// some code
}
// ✅ acceptable
doSomething{ key, value in
// some code
}
The text was updated successfully, but these errors were encountered:
Closing this as a duplicate of #1483. I was concerned about this rule because of the whole SE-0110 discussion, but it seems that is being reverted, so feel free to implement this.
What issues does it prevent? In my own code I've been preferring to always have the parens, but if they can cause problems maybe I should reconsider.
This is just a matter of style, removing extra clutter that is not needed (as parens in ifs for example).
This is a rule request. I'm willing to implement this myself and send a PR, but before doing that I'd like to know if the rule is wanted or not. To explain the desired rule, I'd like to first post the custom rule we are already using in our projects:
I felt like this rule might be useful for other projects as well, which is why I'm posting it. What do you think about it? For us it helps a lot to prevent common issues and enforce a shared style.
Rationale
Xcode always includes parentheses around parameters in closures, even when they are not typed. In these cases they are not needed though and therefore should be omitted.
A few examples:
The text was updated successfully, but these errors were encountered: