Sha256: fd9d6be1b3e55ae0acbeed8eeedf09bc252251843dc655faaddaa7643f6b000e

Contents?: true

Size: 620 Bytes

Versions: 4

Compression:

Stored size: 620 Bytes

Contents

module Reek
  module AST
    #
    # Manages and counts the references out of a method to other objects.
    #
    # @api private
    class ObjectRefs  # :nodoc:
      def initialize
        @refs = Hash.new(0)
      end

      def record_reference_to(exp)
        @refs[exp] += 1
      end

      def references_to(exp)
        @refs[exp]
      end

      def max_refs
        @refs.values.max || 0
      end

      def max_keys
        max = max_refs
        @refs.select { |_key, val| val == max }
      end

      def self_is_max?
        max_keys.length == 0 || @refs[:self] == max_refs
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reek-3.0.3 lib/reek/ast/object_refs.rb
reek-3.0.2 lib/reek/ast/object_refs.rb
reek-3.0.1 lib/reek/ast/object_refs.rb
reek-3.0.0 lib/reek/ast/object_refs.rb