Sha256: 2d95e5aaddc2ad630844dad9b718f2b3e5bbf9e10199886c58c4ed5ea38ac2e0
Contents?: true
Size: 818 Bytes
Versions: 27
Compression:
Stored size: 818 Bytes
Contents
require 'rubygems' require 'sexp_processor' module Reek class ObjectRefs # :nodoc: def initialize @refs = Hash.new(0) end def record_reference_to_self record_ref(SELF_REF) end def record_ref(exp) type = exp[0] case type when :gvar return when :self record_reference_to_self else @refs[exp] += 1 end end def refs_to_self @refs[SELF_REF] end def max_refs @refs.values.max or 0 end # TODO # Should be moved to Hash # def max_keys max = max_refs @refs.reject {|key,val| val != max}.keys end def self_is_max? max_keys.length == 0 || @refs[SELF_REF] == max_refs end private SELF_REF = Sexp.from_array([:lit, :self]) end end
Version data entries
27 entries across 27 versions & 3 rubygems