Sha256: 28655fc448e69585de11433622442a7654bd389560498c7cb655f9870ea09cc5
Contents?: true
Size: 746 Bytes
Versions: 2
Compression:
Stored size: 746 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 rescue Parser::SyntaxError => error AST::EmptyNode.new end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubycritic-1.0.2 | lib/rubycritic/analysers/stats.rb |
rubycritic-1.0.1 | lib/rubycritic/analysers/stats.rb |