Sha256: 6f9d235902b30042592e2c92df89f47fb27915f8153b5d958224813044f6961e

Contents?: true

Size: 1.59 KB

Versions: 35

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

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
      include TextUtil

      DOT = '.'

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

      def started(target_files)
        super
        @offenses_for_files = {}
        output.puts "Inspecting #{pluralize(target_files.size, 'file')}"
      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.size,
                       @total_offense_count,
                       @total_correction_count,
                       @total_correctable_count)
      end

      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
    end
  end
end

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/rubocop-0.91.1/lib/rubocop/formatter/progress_formatter.rb
plaid-14.12.1 vendor/bundle/ruby/3.0.0/gems/rubocop-0.91.1/lib/rubocop/formatter/progress_formatter.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/formatter/progress_formatter.rb
plaid-14.11.1 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/formatter/progress_formatter.rb
plaid-14.10.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/formatter/progress_formatter.rb
plaid-14.7.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/formatter/progress_formatter.rb
rubocop-1.12.1 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.12.0 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.11.0 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.10.0 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.9.1 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.9.0 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.8.1 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.8.0 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.7.0 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.6.1 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.6.0 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.5.2 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.5.1 lib/rubocop/formatter/progress_formatter.rb
rubocop-1.5.0 lib/rubocop/formatter/progress_formatter.rb