Class: NdrDevSupport::Rubocop::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/ndr_dev_support/rubocop/reporter.rb

Overview

Handles the display of any rubocop output

Constant Summary collapse

HEADER =
(('=' * 34) << ' Summary: ' << ('=' * 34)).freeze
('=' * HEADER.length).freeze
COLOURS =
{
  'refactor'   => :yellow,
  'convention' => :yellow,
  'warning'    => :magenta,
  'error'      => :red,
  'fatal'      => :red
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(offenses) ⇒ Reporter

Returns a new instance of Reporter.



18
19
20
# File 'lib/ndr_dev_support/rubocop/reporter.rb', line 18

def initialize(offenses)
  @offenses = Hash[offenses.sort_by { |file, _offenses| file }]
end

Instance Method Details

#reportObject

Prints out a report, and returns an appriopriate exit status for the rake task to terminate with.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ndr_dev_support/rubocop/reporter.rb', line 24

def report
  if @offenses.none?
    warn Rainbow('No relevant changes found.').yellow
    return true
  end

  print_summary
  puts
  print_offenses

  @offenses.values.all?(&:empty?)
end