Sha256: 30489b380ffac1208dd175b2a43861645ee0d0b478256de4f1736eb800a558cb

Contents?: true

Size: 1.46 KB

Versions: 11

Compression:

Stored size: 1.46 KB

Contents

# encoding: utf-8

module RuboCop
  module Formatter
    # 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.
    class ProgressFormatter < ClangStyleFormatter
      def started(target_files)
        super
        @offenses_for_files = {}
        file_phrase = target_files.count == 1 ? 'file' : 'files'
        output.puts "Inspecting #{target_files.count} #{file_phrase}"
      end

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

        report_file_as_mark(offenses)
      end

      def finished(inspected_files)
        output.puts

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

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

        report_summary(inspected_files.count,
                       @total_offense_count,
                       @total_correction_count)
      end

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

        output.write mark
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/formatter/progress_formatter.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/formatter/progress_formatter.rb
rubocop-0.30.1 lib/rubocop/formatter/progress_formatter.rb
rubocop-0.30.0 lib/rubocop/formatter/progress_formatter.rb
rubocop-0.29.1 lib/rubocop/formatter/progress_formatter.rb
rubocop-0.29.0 lib/rubocop/formatter/progress_formatter.rb
rubocop-0.28.0 lib/rubocop/formatter/progress_formatter.rb
rubocop-0.27.1 lib/rubocop/formatter/progress_formatter.rb
rubocop-0.27.0 lib/rubocop/formatter/progress_formatter.rb
rubocop-0.26.1 lib/rubocop/formatter/progress_formatter.rb
rubocop-0.26.0 lib/rubocop/formatter/progress_formatter.rb