Class: Rubocop::Cop::AvoidClassVars

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/avoid_class_vars.rb

Constant Summary collapse

MSG =
'Replace class var %s with a class instance var.'

Instance Attribute Summary

Attributes inherited from Cop

#debug, #disabled_lines, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, cop_name, #has_report?, #ignore_node, inherited, #initialize, #inspect, #name, #on_comment

Constructor Details

This class inherits a constructor from Rubocop::Cop::Cop

Instance Method Details

#on_cvasgn(node) ⇒ Object



8
9
10
11
12
# File 'lib/rubocop/cop/avoid_class_vars.rb', line 8

def on_cvasgn(node)
  class_var, = *node
  add_offence(:convention, node.loc.name.line, sprintf(MSG, class_var))
  super
end