miq_bot icon indicating copy to clipboard operation
miq_bot copied to clipboard

Find cop for preferred methods

Open Fryguy opened this issue 10 years ago • 5 comments

For example prefer .to_sym over .intern.

The existing preferred methods cop only works on collections.

Fryguy avatar Oct 22 '14 14:10 Fryguy

@Fryguy do you have a source for the preferred methods you were thinking of? I can't find anything on the above example.

imtayadeway avatar Jul 30 '15 16:07 imtayadeway

mostly the guide and what in my head like .to_sym over .intern. I was just hoping there was an existing cop that we can configure

Fryguy avatar Jul 30 '15 18:07 Fryguy

i can't find one =) cops tend to be very specific, as with collection methods, deprecated hash methods, class methods, etc...

WDYT about creating our own?

imtayadeway avatar Jul 31 '15 19:07 imtayadeway

This has been partly resolved in https://github.com/bbatsov/rubocop/pull/2204. Like the collection methods, this new cop specifies preferred methods on a specific class/module - in this case String for intern vs to_sym. So I guess in order to continue to expand upon preferred methods we could either continue in this way, or maybe there could be a case for generalizing these cops into a PreferredMethods cop. The latter might not be feasible since the CollectionMethods cop has some special logic for trying to tell if the method in question really is coming from Enumerable ... I'll give this some thought on the best way to proceed.

imtayadeway avatar Sep 03 '15 21:09 imtayadeway

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the traige process documentation.

miq-bot avatar Jun 11 '20 22:06 miq-bot