-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
How to handle ActiveSupport's starts_with? and ends_with? in Performance/DoubleStartEndWith #3893
Comments
I'd go with configuration. On a related note - it would be nice to have a Rails cop checking for usages of the aliases added by |
Thank you. I was leaning towards using a configuration. I figured I would ask before I started implementing this to avoid having to potentially code it twice.
Agreed, this could be a useful cop. It would be really nice if we could come up with a generic solution that could swap out any method with some other method that are defined in configuration. I am not sure how possible a generic solution is because of different method signatures and needed to check for a method called on nothing vs on a variable. |
Guess it will just need more extensive configuration - not just method names. |
I recently discovered that
ActiveSupport
adds instarts_with?
andends_with?
as aliases tostart_with?
andend_with?
. I would like to add support for these methods, but I am not sure what the best way to accomplish this is.One idea is to add a configuration to
Performance/DoubleStartEndWith
to enable checks forstarts_with?
andends_with?
.Another idea is to add a Rails specific cop to handle this check separately from the Performance cop.
What is the preferred way to implement this check?
RuboCop version
Any version that includes
Performance/DoubleStartEndWith
The text was updated successfully, but these errors were encountered: