Class: Evilution::Equivalent::Heuristic::DeadCode

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

Constant Summary collapse

STATEMENT_DELETION_OPERATORS =

Both operators produce statement-deletion-shaped edits. MutationPlanner dedupes by (file_path, mutated_source); whichever operator is registered first surfaces its name on the surviving mutation. Classify equivalence by edit shape, not by operator label, so dead-code classification holds regardless of registry order (EV-74e3 PR #1236 review).

%w[statement_deletion last_expression_removal].to_set.freeze

Instance Method Summary collapse

Instance Method Details

#match?(mutation) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/evilution/equivalent/heuristic/dead_code.rb', line 13

def match?(mutation)
  return false unless STATEMENT_DELETION_OPERATORS.include?(mutation.operator_name)

  node = mutation.subject.node
  return false unless node

  body = node.body
  return false unless body.is_a?(Prism::StatementsNode)

  statements = body.body
  unreachable_lines = find_unreachable_lines(statements)
  unreachable_lines.include?(mutation.line)
end