-
-
Notifications
You must be signed in to change notification settings - Fork 81
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 new Performance/BlockGivenWithExplicitBlock
cop
#173
Add new Performance/BlockGivenWithExplicitBlock
cop
#173
Conversation
Oh, cool, I had to do just that for I'd mark the autocorrection as unsafe, even it's quite unlikely to be: def foo(&block)
block ||= ->(x) { ...}
warn "Using default ..." unless block_given?
foo(&block)
end Or you bail of the autocorrection if the variable is reassigned? |
3885841
to
8756498
Compare
Good point. Updated to not trigger an offense when the block arg is reassigned. |
Sorry I forgot to check this. Don't hesitate to ping me after 2-3 days. |
8756498
to
032993d
Compare
Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Thanks! |
This cop identifies unnecessary use of a
block_given?
where explicit check of block argument would suffice.Benchmark
Results