Skip to content

RuboCop: Switch to `EncforcedStyle: use_builtin_english_names` for `Style/SpecialGlobalVars`

Problem

In !83879 (merged) we've changed EncforcedStyle to use_perl_names for 👮 Style/SpecialGlobalVars to be consistent when using global variables.

When using EncforcedStyle to use_english_names and auto-correcting remaining offenses did fail the pipelines due to missing require 'English'. It was too dangerous to enable this style.

Proposed solution

Switch to 🆕 upstreamed EncforcedStyle: use_builtin_english_names which behaves like EncforcedStyle: use_perl_names but allows the use of $LOADED_FEATURES and $LOAD_PATH since they are builtin and require "English" is not mandatory.

See GitHub issue https://github.com/rubocop/rubocop/issues/5891#issuecomment-1093962138 and merged PR https://github.com/rubocop/rubocop/issues/5891.

Tasks:

  1. Upgrade to RuboCop >= 1.28 which contains https://github.com/rubocop/rubocop/pull/10521
  2. Set EncforcedStyle: use_builtin_english_names for Style/SpecialGlobalVars
  3. Auto-correct offenses via bundle exec rubocop -A --only Style/SpecialGlobalVars (only a few)

Alternative proposal

Switch back to EncforcedStyle: use_english_names.

Tasks:

  1. Upgrade to RuboCop >= 1.19 which contains https://github.com/rubocop/rubocop/pull/9925
  2. Set EncforcedStyle: use_english_names for Style/SpecialGlobalVars
  3. Auto-correct offenses via bundle exec rubocop -A --only Style/SpecialGlobalVars (which adds a bunch of require 'English')

Notes

We've decided to switch the proposed solution in #358427 (comment 911311403).

Edited by Peter Leitzen