Class: Reek::SmellDetectors::NilCheck::NodeFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/reek/smell_detectors/nil_check.rb

Overview

A base class that allows to work on all nodes of a certain type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctx, type, detector) ⇒ NodeFinder

Returns a new instance of NodeFinder.



35
36
37
38
# File 'lib/reek/smell_detectors/nil_check.rb', line 35

def initialize(ctx, type, detector)
  @nodes = ctx.local_nodes(type)
  @detector = detector
end

Instance Attribute Details

#detectorObject (readonly, private)

Returns the value of attribute detector.



48
49
50
# File 'lib/reek/smell_detectors/nil_check.rb', line 48

def detector
  @detector
end

#nodesObject (readonly, private)

Returns the value of attribute nodes.



48
49
50
# File 'lib/reek/smell_detectors/nil_check.rb', line 48

def nodes
  @nodes
end

Instance Method Details

#smelly_nodesObject



40
41
42
43
44
# File 'lib/reek/smell_detectors/nil_check.rb', line 40

def smelly_nodes
  nodes.select do |when_node|
    detector.detect(when_node)
  end
end