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

unused_optional_binding misses ifs inside functions #1237

Closed
keith opened this issue Jan 23, 2017 · 3 comments
Closed

unused_optional_binding misses ifs inside functions #1237

keith opened this issue Jan 23, 2017 · 3 comments
Labels
bug Unexpected and reproducible misbehavior.

Comments

@keith
Copy link
Collaborator

keith commented Jan 23, 2017

This example does not trigger the unused_optional_binding:

func foo() {
    if let _ = bar {
    }
}

If you add this test case:

"func foo() {\nif let _ = bar {\n}\n"

You can see that the tests fail to pass. I believe this is because the if in this case is nested in the substructure of the func, which isn't handled by the current logic

// @rakaramos

@marcelofabri
Copy link
Collaborator

I think this is a problem on the default implementation of ASTRule: https://github.com/realm/SwiftLint/blob/master/Source/SwiftLintFramework/Protocols/ASTRule.swift#L21. It only looks at substructures of the same KindType.

@marcelofabri marcelofabri added the bug Unexpected and reproducible misbehavior. label Jan 23, 2017
@keith
Copy link
Collaborator Author

keith commented Jan 23, 2017

Ah yep! Looks believable. Do you know of any immediate problems we'd have if we "fixed" that?

@marcelofabri
Copy link
Collaborator

I can only think about performance regressions, but we should care more about correctness in this case 😅

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

No branches or pull requests

2 participants