Skip to content
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

has_key? deprecated? #3224

Closed
Aqualon opened this issue Jun 15, 2016 · 3 comments
Closed

has_key? deprecated? #3224

Aqualon opened this issue Jun 15, 2016 · 3 comments

Comments

@Aqualon
Copy link
Contributor

Aqualon commented Jun 15, 2016

The Style/DeprecatedHashMethods cop says, that has_key? is deprecated in favor of key?, citing a four year old message from @matz: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/43765

The ruby 2.3.1 documentation does not mention the deprecation and has_key? is mentioned all over the place, even as example for key?: http://ruby-doc.org/core-2.3.1/Hash.html#method-i-key-3F

So is this really deprecated?

@tejasbubane
Copy link
Contributor

Looking at the doc and source, seems like key? is just an alias of has_key?. Similarly value? is an alias of has_value?.

@mikegee
Copy link
Contributor

mikegee commented Jun 15, 2016

If Matz said it is deprecated, we should assume it won't be in Ruby 3. The only thing missing is a note in the Ruby documentation.

@matz
Copy link

matz commented Jun 15, 2016

Although I prefer key? and recommend to use it over has_key?, it is not going to be removed, even in Ruby3.

tejasbubane added a commit to tejasbubane/rubocop that referenced this issue Jun 16, 2016
Fixes rubocop#3224

As stated by Matz in the discussion in rubocop#3224, the methods
`Hash#has_key?` and `Hash#has_value?` will not be deprecated. Hence
rename the cop and corresponding messages to not use the word deprecated.
bbatsov pushed a commit that referenced this issue Jun 17, 2016
…3226)

Fixes #3224

As stated by Matz in the discussion in #3224, the methods
`Hash#has_key?` and `Hash#has_value?` will not be deprecated. Hence
rename the cop and corresponding messages to not use the word deprecated.
bastelfreak added a commit to bastelfreak/modulesync_config that referenced this issue Jun 30, 2016
 Rename Style/DeprecatedHashMethods to Style/PreferredHashMethods. this
 change happend in the last rubocop release
 rubocop/rubocop#3224
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
…ubocop#3226)

Fixes rubocop#3224

As stated by Matz in the discussion in rubocop#3224, the methods
`Hash#has_key?` and `Hash#has_value?` will not be deprecated. Hence
rename the cop and corresponding messages to not use the word deprecated.
yakschuss added a commit to yakschuss/guides that referenced this issue Oct 30, 2016
This change was officially made in June, and raises a warning when
running rubocop.

"Warning: unrecognized cop Style/DeprecatedHashMethods"

rubocop/rubocop#3224
geoffharcourt pushed a commit to thoughtbot/guides that referenced this issue Jan 12, 2017
This change was officially made in June, and raises a warning when
running rubocop.

"Warning: unrecognized cop Style/DeprecatedHashMethods"

rubocop/rubocop#3224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants