Sha256: 2a68136426a331586818d4ee6c2d2d704a7e76a535b31f034c9c01ef5f38b4ea

Contents?: true

Size: 606 Bytes

Versions: 15

Compression:

Stored size: 606 Bytes

Contents

module Reek
  module Source
    #
    # Locates references to the current object within a portion
    # of an abstract syntax tree.
    #
    class ReferenceCollector
      STOP_NODES = [:class, :module, :def, :defs]

      def initialize(ast)
        @ast = ast
      end

      def num_refs_to_self
        result = 0
        [:self, :zsuper, :ivar, :ivasgn].each do |node_type|
          @ast.look_for(node_type, STOP_NODES) { result += 1 }
        end
        @ast.look_for(:send, STOP_NODES) do |call|
          result += 1 unless call.receiver
        end
        result
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
reek-2.1.0 lib/reek/source/reference_collector.rb
reek-2.0.4 lib/reek/source/reference_collector.rb
reek-2.0.3 lib/reek/source/reference_collector.rb
reek-2.0.2 lib/reek/source/reference_collector.rb
reek-2.0.1 lib/reek/source/reference_collector.rb
reek-2.0.0 lib/reek/source/reference_collector.rb
reek-1.6.6 lib/reek/source/reference_collector.rb
reek-1.6.5 lib/reek/source/reference_collector.rb
reek-1.6.4 lib/reek/source/reference_collector.rb
reek-1.6.3 lib/reek/source/reference_collector.rb
reek-1.6.2 lib/reek/source/reference_collector.rb
reek-1.6.1 lib/reek/source/reference_collector.rb
reek-1.6.0 lib/reek/source/reference_collector.rb
reek-1.5.1 lib/reek/source/reference_collector.rb
reek-1.5.0 lib/reek/source/reference_collector.rb