Class: Nucop::Formatters::GitDiffFormatter

Inherits:
RuboCop::Formatter::ProgressFormatter
  • Object
show all
Defined in:
lib/nucop/formatters/git_diff_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(output, options = {}) ⇒ GitDiffFormatter

Returns a new instance of GitDiffFormatter.



4
5
6
7
8
9
# File 'lib/nucop/formatters/git_diff_formatter.rb', line 4

def initialize(output, options = {})
  super

  populate_history_from_git
  @offenses_per_file = {}
end

Instance Method Details

#file_finished(file, offenses) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/nucop/formatters/git_diff_formatter.rb', line 11

def file_finished(file, offenses)
  return unless file_touched?(file)

  offenses_in_changes = offenses_from_git_history(file, offenses)
  @offenses_per_file[file] = offenses_in_changes.size

  # modify parent Formatter to print what we want
  @offenses_for_files[file] = offenses_in_changes if offenses_in_changes.any?
  report_file_as_mark(offenses_in_changes)
end

#finished(_inspected_files) ⇒ Object



22
23
24
25
26
27
# File 'lib/nucop/formatters/git_diff_formatter.rb', line 22

def finished(_inspected_files)
  @total_offense_count = @offenses_per_file.values.reduce(0, :+)
  @total_correction_count = 0

  super
end