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

Add unused_closure_parameter rule #992

Merged
merged 4 commits into from
Dec 17, 2016
Merged

Add unused_closure_parameter rule #992

merged 4 commits into from
Dec 17, 2016

Conversation

marcelofabri
Copy link
Collaborator

@marcelofabri marcelofabri commented Dec 15, 2016

Fixes #982

This currently doesn't catch some violations:

// 1. If there's a variable with the same name in another object
[1, 2].map { number in
  return otherThing.number
}

// 2. If there're nested closures and the inner one shadows a variable from the other one
[1, 2].map { number in
  return [1, 2].map { number in
    return number + 1
  }
}

1 seems to be possible to be fixed (I just don't have any good ideas). The other one though I'd say is much harder.

Maybe this should be opt-in since it's not a wide-spread convention AFAIK?

@codecov-io
Copy link

codecov-io commented Dec 15, 2016

Current coverage is 82.08% (diff: 95.65%)

Merging #992 into master will increase coverage by 0.15%

@@             master       #992   diff @@
==========================================
  Files           135        136     +1   
  Lines          6362       6413    +51   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           5212       5264    +52   
+ Misses         1150       1149     -1   
  Partials          0          0          

Powered by Codecov. Last update 5c6d996...d2b9c72

@jpsim
Copy link
Collaborator

jpsim commented Dec 16, 2016

Do you have a job? Or do you just write awesome SwiftLint rules for a living? 😛

@jpsim
Copy link
Collaborator

jpsim commented Dec 16, 2016

I made some small changes in d2b9c72, I hope you don't mind. I feel like this could easily be made correctable. Do you think you can do that in this PR, or should we merge this as-is?

@marcelofabri
Copy link
Collaborator Author

Do you have a job? Or do you just write awesome SwiftLint rules for a living? 😛

I'll take that as a compliment 😂

I made some small changes in d2b9c72, I hope you don't mind. I feel like this could easily be made correctable. Do you think you can do that in this PR, or should we merge this as-is?

I think we can merge this now and later make it correctable. I feel we should create a better way to have correctable ASTRules to take advantage of the methods in ASTRule protocol.

@jpsim
Copy link
Collaborator

jpsim commented Dec 17, 2016

Sounds good! Let's get this in.

@jpsim jpsim merged commit 46de14c into realm:master Dec 17, 2016
@marcelofabri marcelofabri deleted the unused-closure-parameter branch December 17, 2016 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unused parameter in closure should be replaced with _
3 participants