Class: RuboCop::Formatter::ProgressFormatter Private

Inherits:
ClangStyleFormatter show all
Includes:
TextUtil
Defined in:
lib/rubocop/formatter/progress_formatter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This formatter display dots for files with no offenses and letters for files with problems in the them. In the end it appends the regular report data in the clang style format.

Direct Known Subclasses

AutoGenConfigFormatter

Constant Summary collapse

DOT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'.'

Constants inherited from ClangStyleFormatter

ClangStyleFormatter::ELLIPSES

Constants inherited from SimpleTextFormatter

SimpleTextFormatter::COLOR_FOR_SEVERITY

Constants included from PathUtil

PathUtil::HIDDEN_FILE_PATTERN

Instance Attribute Summary

Attributes inherited from BaseFormatter

#options, #output

Instance Method Summary collapse

Methods included from TextUtil

pluralize

Methods inherited from ClangStyleFormatter

#report_file

Methods inherited from SimpleTextFormatter

#report_file, #report_summary

Methods included from PathUtil

absolute?, glob?, hidden_dir?, hidden_file?, hidden_file_in_not_hidden_dir?, match_path?, maybe_hidden_file?, relative_path, smart_path

Methods included from Colorizable

#colorize, #rainbow

Methods inherited from BaseFormatter

#file_started

Constructor Details

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ProgressFormatter.


13
14
15
16
# File 'lib/rubocop/formatter/progress_formatter.rb', line 13

def initialize(output, options = {})
  super
  @dot = green(DOT)
end

Instance Method Details

#file_finished(file, offenses) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


24
25
26
27
28
29
30
31
# File 'lib/rubocop/formatter/progress_formatter.rb', line 24

def file_finished(file, offenses)
  unless offenses.empty?
    count_stats(offenses)
    @offenses_for_files[file] = offenses
  end

  report_file_as_mark(offenses)
end

#finished(inspected_files) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rubocop/formatter/progress_formatter.rb', line 33

def finished(inspected_files)
  output.puts

  unless @offenses_for_files.empty?
    output.puts
    output.puts 'Offenses:'
    output.puts

    @offenses_for_files.each { |file, offenses| report_file(file, offenses) }
  end

  report_summary(inspected_files.size,
                 @total_offense_count,
                 @total_correction_count,
                 @total_correctable_count)
end

#report_file_as_mark(offenses) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


50
51
52
53
54
55
56
57
58
59
# File 'lib/rubocop/formatter/progress_formatter.rb', line 50

def report_file_as_mark(offenses)
  mark = if offenses.empty?
           @dot
         else
           highest_offense = offenses.max_by(&:severity)
           colored_severity_code(highest_offense)
         end

  output.write mark
end

#started(target_files) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


18
19
20
21
22
# File 'lib/rubocop/formatter/progress_formatter.rb', line 18

def started(target_files)
  super
  @offenses_for_files = {}
  output.puts "Inspecting #{pluralize(target_files.size, 'file')}"
end