module Reek::SmellDetectors::NilCheck::NilCallNodeDetector
Detect ‘call’ nodes which perform a nil check.
Public Instance Methods
Source
# File lib/reek/smell_detectors/nil_check.rb, line 69 def comparison_call?(call) comparison_methods.include? call.name end
Source
# File lib/reek/smell_detectors/nil_check.rb, line 77 def comparison_methods [:==, :===] end
Source
# File lib/reek/smell_detectors/nil_check.rb, line 57 def detect(node) nil_query?(node) || nil_comparison?(node) end
Source
# File lib/reek/smell_detectors/nil_check.rb, line 73 def involves_nil?(call) call.participants.any? { |it| it.type == :nil } end
Source
# File lib/reek/smell_detectors/nil_check.rb, line 65 def nil_comparison?(call) comparison_call?(call) && involves_nil?(call) end
Source
# File lib/reek/smell_detectors/nil_check.rb, line 61 def nil_query?(call) call.name == :nil? end