Add new Performance/BlockGivenWithExplicitBlock cop#173
Merged
koic merged 1 commit intorubocop:masterfrom Oct 17, 2020
Merged
Conversation
Contributor
|
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)
endOr you bail of the autocorrection if the variable is reassigned? |
3885841 to
8756498
Compare
Contributor
Author
|
Good point. Updated to not trigger an offense when the block arg is reassigned. |
koic
approved these changes
Oct 16, 2020
marcandre
requested changes
Oct 16, 2020
Contributor
|
Sorry I forgot to check this. Don't hesitate to ping me after 2-3 days. |
8756498 to
032993d
Compare
Contributor
Author
|
Updated. |
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This cop identifies unnecessary use of a
block_given?where explicit check of block argument would suffice.Benchmark
Results