lib/rubocop/cop/style/special_global_vars.rb in rubocop-0.68.1 vs lib/rubocop/cop/style/special_global_vars.rb in rubocop-0.69.0

- old
+ new

@@ -59,14 +59,14 @@ class SpecialGlobalVars < Cop include ConfigurableEnforcedStyle MSG_BOTH = 'Prefer `%<prefer>s` from the stdlib \'English\' ' \ 'module (don\'t forget to require it) or `%<regular>s` over ' \ - '`%<global>s`.'.freeze + '`%<global>s`.' MSG_ENGLISH = 'Prefer `%<prefer>s` from the stdlib \'English\' ' \ - 'module (don\'t forget to require it) over `%<global>s`.'.freeze - MSG_REGULAR = 'Prefer `%<prefer>s` over `%<global>s`.'.freeze + 'module (don\'t forget to require it) over `%<global>s`.' + MSG_REGULAR = 'Prefer `%<prefer>s` over `%<global>s`.' ENGLISH_VARS = { # rubocop:disable Style/MutableConstant :$: => [:$LOAD_PATH], :$" => [:$LOADED_FEATURES], :$0 => [:$PROGRAM_NAME], @@ -138,11 +138,11 @@ def autocorrect(node) lambda do |corrector| global_var, = *node - while node.parent && node.parent.begin_type? && + while node.parent&.begin_type? && node.parent.children.one? node = node.parent end corrector.replace(node.source_range, replacement(node, global_var)) @@ -178,10 +178,10 @@ def format_list(items) items.join('` or `') end def replacement(node, global_var) - parent_type = node.parent && node.parent.type + parent_type = node.parent&.type preferred_name = preferred_names(global_var).first unless %i[dstr xstr regexp].include?(parent_type) return preferred_name.to_s end