-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 iterator?
to deprecated methods and prefer block_given?
#6714
Add iterator?
to deprecated methods and prefer block_given?
#6714
Conversation
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.
The code looks good to me. I think we should add autocorrect support to the cop. I'm not a big fan of the name KernelIteratorPredicate
. I don't think most people realize that iterator?
even exists.
Would you be open to adding auto-correct @tejasbubane? It involves defining an def autocorrect(node)
lambda do |corrector|
corrector.replace(node.source_range, 'block_given?')
end
end I haven't tested it though. 🙂 |
@Drenmi yes I will add autocorrect and make all the changes today. Thanks! |
I don’t think this warrants a dedicated cop. Probably it should be part of some generic cop about preferred methods. I know we have some offenders in the current codebase, but we shouldn’t grow that list. |
Which cop do you think this should go in? Create a new one called |
We have an existing cop called |
|
cd8affc
to
c9cf7f2
Compare
I have made the changes to use |
c9cf7f2
to
67ca438
Compare
Lint/KernalIteratorPredicate
copiterator?
to deprecated methods and prefer block_given?
082cf25
to
4d66c8b
Compare
4d66c8b
to
841f095
Compare
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.
Thank you 🙏
Looks good @tejasbubane! I'm ready to accept the code as is, but it would be cool, since it's a Maybe the code already does this, but the unit test seems to be missing. 🙂 |
…block_given?`
841f095
to
5c957cd
Compare
Yes the code already checked for |
This is less about this specific change and might require further discussion outside of this PR, but I noticed that this cop is marked as Maybe it's good to define Has someone defined a specific policy for what counts as |
You're asking good questions, @dgollahon. We don't have a formal definition of this at the moment. It was also relatively recently we started marking cops as unsafe, so I haven't given this a lot of thought. On first thought, I also prefer that "safe" is truly safe, although it could turn out (I don't have a good feel of this) that it would disqualify a very large subset of cops, which might be the wrong trade-off. 🤔 |
Closes #6688
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.