Class: Attractor::ConsoleReporter::JSONFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/attractor/reporters/console_reporter.rb

Instance Method Summary collapse

Instance Method Details

#call(calculators) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/attractor/reporters/console_reporter.rb', line 53

def call(calculators)
  result = calculators.map do |calc|
    type = calc.last.type
    values = calc.last.calculate
    suggester = Suggester.new(values)
    to_be_refactored = suggester.suggest.map(&:file_path)

    [
      type, values.map do |value|
        {
          file_path: value.file_path,
          score: value.score,
          complexity: value.complexity,
          churn: value.churn,
          refactor: to_be_refactored.include?(value.file_path),
          details: value.details,
          history: value.history
        }
      end
    ]
  end

  puts result.to_h.to_json
end