-
-
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
Customizing the preference of has_key? vs key? #3428
Comments
This cop is not configurable, but I agree that it should be. |
I thought that |
In this thread, Matz mentions that it won't be removed (even in Rails 3). At this point, it's not really deprecated. The Ruby team prefers |
I would like to tackle this issue for hacktoberfest. |
Great! |
Sorry. I feel like I overcommitted in the moment. I haven’t had time to work on this issue. I wanted to let you all know. Thanks. |
@johndavidmartinez: Don't worry about it. You're welcome back when you think you have the time. 😀 |
Hope you don't mind @johndavidmartinez, just came across this earlier and was keen to see it included. #3579 includes options for |
…with short (default) or verbose method naming
…with short (default) or verbose method naming
Matz and rubocop prefer
key?
andvalue?
tohas_key?
andhas_value?
. This is a step backwards in readability. People rarely walk up to another person and just saykey?
, but when they do, they also give some other cue like holding out a hand or inflecting their voice. Simply sayingkey?
is ambiguous as it could mean "do you have the key?", "did you ever have the key?", "can I have the key?", etc...IMHO, adding a question mark to the end of a method is not a substitute for dropping a meaningful prefix, but rubyists have a convention of dropping "is" and "has" from the start of method names and many people like it.
I'm trying to configure this cop to prefer
has_key?
andhas_value?
, but I'm not sure if this is possible. (I don't want to disable it outright because there may be other method suggestions that I would like to know about in the future.) I didn't see an example of how to customize this in theconfig/default.yml
, so I tried customizing this with :I got the following error output
Is customizing this cop supported?
RuboCop version
0.42.0 (using Parser 2.3.1.2, running on ruby 2.3.1 x86_64-linux)
The text was updated successfully, but these errors were encountered: