class Reek::SmellDetectors::NilCheck
Checking for nil is a special kind of type check, and therefore a case of SimulatedPolymorphism.
See {file:docs/Nil-Check.md} for details.
Public Instance Methods
Source
# File lib/reek/smell_detectors/nil_check.rb, line 12 def sniff lines = detect_nodes.map(&:line) if lines.any? [smell_warning( lines: lines, message: 'performs a nil-check')] else [] end end
Private Instance Methods
Source
# File lib/reek/smell_detectors/nil_check.rb, line 25 def detect_nodes finders = [NodeFinder.new(context, :send, NilCallNodeDetector), NodeFinder.new(context, :when, NilWhenNodeDetector)] finders.flat_map(&:smelly_nodes) end