Sha256: a032cfb4afed4c0387b7178ea7e1b1a0e52c60b2550bf10629e50da62790e978

Contents?: true

Size: 677 Bytes

Versions: 1

Compression:

Stored size: 677 Bytes

Contents

require "parser/current"
require "rubycritic/analysers/adapters/ast_node"

module Rubycritic
  module Analyser

    class Stats
      def initialize(analysed_files)
        @analysed_files = analysed_files
      end

      def run
        @analysed_files.each do |analysed_file|
          analysed_file.methods_count = methods_count(analysed_file.path)
        end
      end

      private

      def methods_count(path)
        content = File.read(path)
        node = parse_content(content)
        node.count_nodes_of_type(:def, :defs)
      end

      def parse_content(content)
        Parser::CurrentRuby.parse(content) || AST::EmptyNode.new
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubycritic-1.0.0 lib/rubycritic/analysers/stats.rb