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

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#match?(mutation) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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