Sha256: 4d1ee5bcafdfdd617b18135d5e2033a8d109f96390c3eaa7155cf4ffaf336327
Contents?: true
Size: 1002 Bytes
Versions: 1
Compression:
Stored size: 1002 Bytes
Contents
$:.unshift File.dirname(__FILE__) require 'rubygems' require 'sexp' require 'reek/printer' module Reek class ObjectRefs def initialize @refs = Hash.new(0) record_reference_to_self 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; but Hash has 58 methods, and there's currently # no way to turn off that report; which would therefore make the tests fail def max_keys max = max_refs @refs.reject {|k,v| v != 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reek-0.3.1 | lib/reek/object_refs.rb |