123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::Formatter::ProgressFormatter

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: RuboCop::Formatter::ClangStyleFormatter
Defined in: lib/rubocop/formatter/progress_formatter.rb

Overview

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.

Constant Summary

::RuboCop::PathUtil - Included

HIDDEN_FILE_PATTERN, SMART_PATH_CACHE

SimpleTextFormatter - Inherited

COLOR_FOR_SEVERITY

ClangStyleFormatter - Inherited

ELLIPSES

Class Method Summary

Instance Attribute Summary

Instance Method Summary

TextUtil - Included

ClangStyleFormatter - Inherited

SimpleTextFormatter - Inherited

::RuboCop::PathUtil - Included

#absolute?

Returns true for an absolute Unix or Windows path.

#glob?

Returns true for a glob.

#hidden_dir?, #hidden_file?, #hidden_file_in_not_hidden_dir?,
#match_path?

Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.

#maybe_hidden_file?

Loose check to reduce memory allocations.

#relative_path, #smart_path

Colorizable - Included

BaseFormatter - Inherited

#file_finished

Invoked at the end of inspecting each files.

#file_started

Invoked at the beginning of inspecting each files.

#finished

Invoked after all files are inspected or interrupted by user.

#started

Invoked once before any files are inspected.

Constructor Details

.new(output, options = {}) ⇒ ProgressFormatter

[ GitHub ]

  
# 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)

[ GitHub ]

  
# 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)

[ GitHub ]

  
# 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)

[ GitHub ]

  
# 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)

[ GitHub ]

  
# 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