Class: CustomCops::InstanceEval

Inherits:
RuboCop::Cop::Base
  • Object
show all
Defined in:
lib/simplycop/custom_cops/instance_eval.rb

Overview

This cop checks for usages of ‘instance_eval`

Examples:

#bad
class Person
end

Person.instance_eval do
  def human?
    true
  end
end

#good
class Person
  def self.human?
    true
  end
end

Constant Summary collapse

MSG =
'Avoid instance_eval.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



29
30
31
32
33
# File 'lib/simplycop/custom_cops/instance_eval.rb', line 29

def on_send(node)
  return unless instance_evaling?(node)

  add_offense(node.loc.selector)
end