Quantcast
Channel: User Schwern - Stack Overflow
Viewing all articles
Browse latest Browse all 581

Answer by Schwern for How can I warn about Ruby 3 deprecated code, while using Ruby 2.7 with Rubocop?

$
0
0

Rubocop has a few lints to detect deprecated Ruby features. For example, Lint/DeprecatedClassMethods. For most of these Rubocop doesn't care what version of Ruby you're using.

To find more issues, set your TargetRubyVersion to 3.0 (or whatever your target is).

AllCops:  TargetRubyVersion: 3.0

Some cops which might be useful to you are not enabled by default because they're not 100% safe. You may wish to enable them.

Add this to your automated code review checks.


You can add your own custom cops to detect more 3.0 deprecated features. Reading the code for the existing cops looking for deprecations will help.

I don't know of a rubocop extension specifically dedicated to Ruby upgrade cops. You could even bundle this up into rubocop-deprecations.


Viewing all articles
Browse latest Browse all 581

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>