Add new Lint/DeprecatedConstants cop#9324
Conversation
7df54a1 to
abe9fc4
Compare
|
Nice cop, but it might also be a good idea to add some data about the Ruby version where something got deprecated to the config as well. This will allow us to have more informative messages. |
abe9fc4 to
dbdef11
Compare
|
That's good idea! I added deprecated version for deprecated constants. |
There was a problem hiding this comment.
"deprecated since" would be a slightly better wording here
There was a problem hiding this comment.
I see! Thank your for the suggestion!
dbdef11 to
32915a2
Compare
There was a problem hiding this comment.
I'm not sure whether array is good. For example, hash may be preferable. Please let me know if you have feedback 😅
There was a problem hiding this comment.
I agree that hash would be better. This would spare us from having to use explicit nulls.
There was a problem hiding this comment.
This would spare us from having to use explicit
nulls.
Sure! That makes sense :-) I updated it!
32915a2 to
f33ca14
Compare
This PR adds new `Lint/DeprecatedConstants` cop. This cop checks for deprecated constants. It has `DeprecatedConstants` config. If there is an alternative method, you can set alternative value as `Alternative`. And you can set the deprecated version as `DeprecatedVersion`. These options can be omitted if they are not needed. By default, `NIL`, `TRUE`, `FALSE` and `Random::DEFAULT` are configured. ```ruby # bad NIL TRUE FALSE Random::DEFAULT # Return value of Ruby 2 is `Random` instance, Ruby 3.0 is `Random` class. # good nil true false Random.new # `::DEFAULT` has been deprecated in Ruby 3, `.new` is compatible with Ruby 2. ``` The following are these sources of information. - Remove (deprecated) `NIL`, `TRUE`, and `FALSE` ... ruby/ruby@62554ca - Deprecate `Random::DEFAULT` ... https://bugs.ruby-lang.org/issues/17351
f33ca14 to
b95afa7
Compare
|
Thanks! |
This PR adds new
Lint/DeprecatedConstantscop.This cop checks for deprecated constants.
It has
DeprecatedConstantsoption. If there is an alternative method, you can set the value as a string. Or setnullto the value if there is no alternative.By default,
NIL,TRUE,FALSEandRandom::DEFAULTare configured.The following are these sources of information.
NIL,TRUE, andFALSE... ruby/ruby@62554caRandom::DEFAULT... https://bugs.ruby-lang.org/issues/17351Before submitting the PR make sure the following are checked:
[Fix #issue-number](if the related issue exists).master(if not - rebase it).bundle exec rake default. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.mdif the new code introduces user-observable changes. See changelog entry format for details.