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_autocorrect: false) ⇒ Report

rubocop:disable Metrics/ParameterLists



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

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

Instance Method Details

#summaryObject

rubocop:enable Metrics/ParameterLists



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

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