Class: Evilution::Mutator::Operator::BangMethod

Inherits:
Base
  • Object
show all
Defined in:
lib/evilution/mutator/operator/bang_method.rb

Constant Summary collapse

KNOWN_BANG_PAIRS =
%i[
  sort map collect select reject uniq compact flatten
  shuffle reverse slice gsub sub strip chomp chop squeeze
  delete encode merge update save
].to_set.freeze

Instance Attribute Summary

Attributes inherited from Base

#mutations

Instance Method Summary collapse

Methods inherited from Base

#call, clear_parse_cache!, #initialize, operator_name, parsed_tree_for

Constructor Details

This class inherits a constructor from Evilution::Mutator::Base

Instance Method Details

#visit_call_node(node) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/evilution/mutator/operator/bang_method.rb', line 12

def visit_call_node(node)
  return super unless node.receiver

  loc = node.message_loc
  return super unless loc

  name = node.name.to_s

  if name.end_with?("!")
    generate_non_bang(node, loc, name)
  elsif KNOWN_BANG_PAIRS.include?(node.name)
    generate_bang(node, loc, name)
  end

  super
end