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

Inherits:
Base
  • Object
show all
Defined in:
lib/evilution/mutator/operator/bang_method.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.

Constant Summary collapse

KNOWN_BANG_PAIRS =

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

%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

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.



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