Class: RuboCop::Formatter::SimpleTextFormatter::Report

Inherits:
Object
  • Object
show all
Includes:
Colorizable, TextUtil
Defined in:
lib/rubocop/formatter/simple_text_formatter.rb

Overview

A helper class for building the report summary text.

Instance Method Summary collapse

Methods included from TextUtil

pluralize

Methods included from Colorizable

#colorize

Constructor Details

#initialize(file_count, offense_count, correction_count, correctable_count, rainbow, safe_auto_correct: false) ⇒ Report

rubocop:disable Metrics/ParameterLists


109
110
111
112
113
114
115
116
117
118
119
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 109

def initialize(
  file_count, offense_count, correction_count, correctable_count, rainbow,
  safe_auto_correct: false
)
  @file_count = file_count
  @offense_count = offense_count
  @correction_count = correction_count
  @correctable_count = correctable_count
  @rainbow = rainbow
  @safe_auto_correct = safe_auto_correct
end

Instance Method Details

#summaryObject

rubocop:enable Metrics/ParameterLists


122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 122

def summary
  if @correction_count.positive?
    if @correctable_count.positive?
      "#{files} inspected, #{offenses} detected, #{corrections} corrected,"\
        " #{correctable}"
    else
      "#{files} inspected, #{offenses} detected, #{corrections} corrected"
    end
  elsif @correctable_count.positive?
    "#{files} inspected, #{offenses} detected, #{correctable}"
  else
    "#{files} inspected, #{offenses} detected"
  end
end