class Rubocop::Cop::Style::AvoidGlobalVars

This cops looks for uses of global variables. It does not report offences for built-in global variables.

Constants

BUILT_IN_VARS

predefined global variables their English aliases www.zenspider.com/Languages/Ruby/QuickRef.html

MSG

Public Instance Methods

check(node) click to toggle source
# File lib/rubocop/cop/style/avoid_global_vars.rb, line 53
def check(node)
  global_var, = *node

  unless BUILT_IN_VARS.include?(global_var.to_s)
    add_offence(:convention,
                node.loc.name,
                MSG)
  end
end
on_gvar(node) click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/avoid_global_vars.rb, line 41
def on_gvar(node)
  check(node)

  super
end
on_gvasgn(node) click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/avoid_global_vars.rb, line 47
def on_gvasgn(node)
  check(node)

  super
end