Class: MOSAIK::Metrics::ABCSize::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/mosaik/metrics/abc_size/parser.rb

Overview

Parser for Ruby code

Instance Method Summary collapse

Instance Method Details

#parse(file) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mosaik/metrics/abc_size/parser.rb', line 13

def parse(file)
  debug "Parsing file: #{file}"

  # Parse Abstract Syntax Tree
  source = RuboCop::AST::ProcessedSource
    .new(File.read(file), 3.3)

  # Process AST to extract ABC sizes from methods
  processor = Processor.new

  source.ast.each_node do |node|
    processor
      .process(node)
  end

  processor.abc_sizes
end