Class: Rubocop::Cop::AvoidClassVars

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

Instance Attribute Summary

Attributes inherited from Cop

#correlations, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, #has_report?, inherited, #initialize

Constructor Details

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

Instance Method Details

#inspect(file, source, tokens, sexp) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rubocop/cop/avoid_class_vars.rb', line 6

def inspect(file, source, tokens, sexp)
  each(:@cvar, sexp) do |s|
    class_var = s[1]
    lineno = s[2].lineno

    add_offence(
      :convention,
      lineno,
      "Replace class var #{class_var} with a class instance var."
    )
  end
end