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 Style/ExplicitBlockArgument
cop
#8415
Conversation
include RangeHelp | ||
extend AutoCorrector | ||
|
||
MSG = 'Consider using explicit block argument.' |
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.
I think this message is a bit confusing, as it's not very clear where is this argument supposed to be. Perhaps something like "Consider using explicit block argument in the surrounding method's signature over yield
." or something along those lines.
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.
Corrected.
e52c8df
to
5f02f80
Compare
Please mark as unsafe (as it may change the yielding arity) |
5f02f80
to
a591ac2
Compare
Btw, I've been thinking it'd be great if we started to add to the cop descriptions some explanations as to what exactly makes them unsafe so it's more obvious for the users. |
Yes, I have the same thought and already added a line about this )) |
Thanks! |
Yes! With an example too...
|
Going forward I think we should also add such explanation and examples to the cop description from which the documentation is generated. |
I created #8431 |
Follow rubocop/rubocop#8415 This commit suppresses the following `Style/ExplicitBlockArgument`'s offenses. ```console % bundle exec rake (snip) Offenses: lib/rubocop/rails/schema_loader/schema.rb:105:13: C: Style/ExplicitBlockArgument: Consider using explicit block argument in the surrounding method's signature over yield. node.body.children.each do |child| ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 181 files inspected, 1 offense detected RuboCop failed! ```
https://rubystyle.guide/#block-argument
Consider using explicit block argument to avoid writing block literal that just passes its arguments to another block.