Review rubocop rules for Ruby 3 readiness
Our current Cops scan for issues that are known violations in Ruby 2. However, some of these are specific to particular Ruby versions. One such example is Style/RedundantFreeze. In Ruby 2, Regexp and Range instances must be explicitly frozen via freeze
(these are not literals so are not covered by the frozen_strings
pragma). In Ruby 3, these instances are auto-frozen by the VM on creation.
So for code to pass linting on both Ruby 2 and 3, we need to silence this cop. There may be more instances where such incompatibilities exist, which we may want to review.
Things to keep in mind:
- as long as we are not running Ruby 3 in production, we should not silence cops that may let issues slip past us that could cause problems in Ruby 2
- since we need to run pipelines in parallel for a while, we need to accommodate both runtimes
- we should investigate whether we can automatically enable a Ruby version-specific rule set to sidestep these issues and to allow for a graceful rollout
Edited by Matthias Käppler