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

closure_parameter_position not triggering with lack of parameter in closure #3225

Closed
2 tasks done
gannon-eero opened this issue Jun 5, 2020 · 1 comment · Fixed by #3281
Closed
2 tasks done

closure_parameter_position not triggering with lack of parameter in closure #3225

gannon-eero opened this issue Jun 5, 2020 · 1 comment · Fixed by #3281
Labels
bug Unexpected and reproducible misbehavior.

Comments

@gannon-eero
Copy link

gannon-eero commented Jun 5, 2020

New Issue Checklist

What I expected from this rule was that regardless of whether there was a parameter or not (although I understand it does go against the name of the rule in a sense), it would still trigger. Instead, I would expect the rule to really apply to the in syntax altogether. For instance, this currently triggers:

closureFunc {
    [weak self] param in
    ...
}

However, this does not

closureFunc {
    [weak self] in
    ...
}

This appears kind of odd, when you have multiple closures for a function with some with parameters and some without, such as below. The middle onFailure closure will trigger, but the onSuccess and onReset do not.

thing.doStuff(onSuccess: {
    [weak self] in
    doSuccess()
}, onFailure: {
    [weak self] rules in
    doFailure()
}, onReset: {
    [weak self] in
    doReset()
})

Will update this if I figure out a good custom rule or change that achieves this result.

@gannon-eero
Copy link
Author

gannon-eero commented Jun 5, 2020

Likewise, in the situation where the closure is a member variable of a struct/class, the rule also doesn't trigger. Such as:

struct Foo {
    var completionHandler: ((Int) -> Void)? = nil
}

var f = Foo()
f.completionHandler = {
    thing in // Should trigger here
    doStuff()
}

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

Successfully merging a pull request may close this issue.

2 participants