<commit_before>module Mutant
  # Generator for mutations
  class Mutator
    include Adamantium::Flat, AbstractType

    # Run mutator on input
    #
    # @param [Parser::AST::Node] node
    # @param [#call] block
    #
    # @return [self]
    #
    # @api private
    #
    def self.each(node, &block)
      return to_enum(__method__, node) unless block_given?
      Registry.lookup(node).new(node, block)

      self
    end

    # Register node class handler
    #
    # @return [undefined]
    #
    # @api private
    #
    def self.handle(*types)
      types.each do |type|
        Registry.register(type, self)
      end
    end
    private_class_method :handle

    # Return identity of object (for deduplication)
    #
    # @param [Object] object
    #
    # @return [Object]
    #
    # @api private
    #
    def self.identity(object)
      object
    end

    # Return input
    #
    # @return [Object]
    #
    # @api private
    #
    attr_reader :input

  private

    # Initialize object
    #
    # @param [Object] input
    # @param [#call(node)] block
    #
    # @return [undefined]
    #
    # @api private
    #
    def initialize(input, block)
      @input, @block = IceNine.deep_freeze(input), block
      @seen = Set.new
      guard(input)
      dispatch
    end

    # Test if generated object is not guarded from emmitting
    #
    # @param [Object] object
    #
    # @return [true]
    #   if generated object is different
    #
    # @return [false]
    #
    # @api private
    #
    def new?(object)
      !@seen.include?(self.class.identity(object))
    end

    # Add object to guarded values
    #
    # @param [Object] object
    #
    # @return [undefined]
    #
    # @api private
    #
    def guard(object)
      @seen << self.class.identity(object)
    end

    # Test if generated mutation is allowed
    #
    # @param [Object] object
    #
    # @return [true]
    #   if mutation is allowed
    #
    # @return [false]
    #   otherwise
    #
    # @api private
    #
    def allow?(object)
      true
    end

    # Dispatch node generations
    #
    # @return [undefined]
    #
    # @api private
    #
    abstract_method :dispatch

    # Emit generated mutation if object is not equivalent to input
    #
    # @param [Object] object
    #
    # @return [undefined]
    #
    # @api private
    #
    def emit(object)
      return unless new?(object) and allow?(object)
<commit_msg>Remove unused in-mutator mutation filter<commit_after>module Mutant
  # Generator for mutations
  class Mutator
    include Adamantium::Flat, AbstractType

    # Run mutator on input
    #
    # @param [Parser::AST::Node] node
    # @param [#call] block
    #
    # @return [self]
    #
    # @api private
    #
    def self.each(node, &block)
      return to_enum(__method__, node) unless block_given?
      Registry.lookup(node).new(node, block)

      self
    end

    # Register node class handler
    #
    # @return [undefined]
    #
    # @api private
    #
    def self.handle(*types)
      types.each do |type|
        Registry.register(type, self)
      end
    end
    private_class_method :handle

    # Return identity of object (for deduplication)
    #
    # @param [Object] object
    #
    # @return [Object]
    #
    # @api private
    #
    def self.identity(object)
      object
    end

    # Return input
    #
    # @return [Object]
    #
    # @api private
    #
    attr_reader :input

  private

    # Initialize object
    #
    # @param [Object] input
    # @param [#call(node)] block
    #
    # @return [undefined]
    #
    # @api private
    #
    def initialize(input, block)
      @input, @block = IceNine.deep_freeze(input), block
      @seen = Set.new
      guard(input)
      dispatch
    end

    # Test if generated object is not guarded from emmitting
    #
    # @param [Object] object
    #
    # @return [true]
    #   if generated object is different
    #
    # @return [false]
    #
    # @api private
    #
    def new?(object)
      !@seen.include?(self.class.identity(object))
    end

    # Add object to guarded values
    #
    # @param [Object] object
    #
    # @return [undefined]
    #
    # @api private
    #
    def guard(object)
      @seen << self.class.identity(object)
    end

    # Dispatch node generations
    #
    # @return [undefined]
    #
    # @api private
    #
    abstract_method :dispatch

    # Emit generated mutation if object is not equivalent to input
    #
    # @param [Object] object
    #
    # @return [undefined]
    #
    # @api private
    #
    def emit(object)
      return unless new?(object)

{'fraction_non_alphanumeric': 0.1043872919818457, 'fraction_numerical': 0.0, 'mean_word_length': 1.9609724888035829, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5733284', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1449, 'n_words': 390}