Class: Evilution::Equivalent::Heuristic::MethodBodyNil

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/equivalent/heuristic/method_body_nil.rb

Instance Method Summary collapse

Instance Method Details

#match?(mutation) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/evilution/equivalent/heuristic/method_body_nil.rb', line 6

def match?(mutation)
  return false unless mutation.operator_name == "method_body_replacement"

  node = mutation.subject.node
  return false unless node

  body = node.body
  return true if body.nil? || body.is_a?(Prism::NilNode)

  return body.body.first.is_a?(Prism::NilNode) if body.is_a?(Prism::StatementsNode) && body.body.length == 1

  false
end