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 cop Lint/UnexpectedBlockArity
#9112
Conversation
Overall the cop looks great. My only suggestion would be to ignore method calls without receivers, as those are going to be more likely to be false positives. |
92bed5f
to
3f0facd
Compare
@bbatsov makes sense! I've updated it. |
Thanks! |
Would it be possible to add We have a lot of
|
@inkstak configuring the cop like this probably would solve this for you: Lint/UnexpectedBlockArity:
Exclude:
- '**/*.jbuilder' |
@dvandersluis Yes this is my current workaround, but it's too bad that this helpful cop doesn't cover regular |
There isn't really a way for rubocop to know if |
(until we plug into |
I actually suspect we can't tell what type is the receiver, but isn't it impossible to exclude cases using the name of the receiver or the whole line ? I humbly ask, the subtleties of rubocop parser are still beyonds me.
Still, some real uses of |
Follows #9071 (comment):
This new cop checks for method blocks where the given block args don't match what the method is known to need. It is configurable using
Methods
, which is preloaded with all theEnumerable
methods that take 2 args, as per the above comment.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.