class RuboCop::Formatter::SimpleTextFormatter::Report
A helper class for building the report summary text.
Attributes
rainbow[R]
Public Class Methods
new( file_count, offense_count, correction_count, correctable_count, rainbow, safe_autocorrect: false )
click to toggle source
rubocop:disable Metrics/ParameterLists
# 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
Public Instance Methods
summary()
click to toggle source
rubocop:enable Metrics/ParameterLists
# 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
Private Instance Methods
correctable()
click to toggle source
# File lib/rubocop/formatter/simple_text_formatter.rb, line 160 def correctable if @safe_autocorrect text = pluralize(@correctable_count, 'more offense') "#{colorize(text, :yellow)} can be corrected with `rubocop -A`" else text = pluralize(@correctable_count, 'offense') "#{colorize(text, :yellow)} autocorrectable" end end
corrections()
click to toggle source
# File lib/rubocop/formatter/simple_text_formatter.rb, line 153 def corrections text = pluralize(@correction_count, 'offense') color = @correction_count == @offense_count ? :green : :cyan colorize(text, color) end
files()
click to toggle source
# File lib/rubocop/formatter/simple_text_formatter.rb, line 142 def files pluralize(@file_count, 'file') end
offenses()
click to toggle source
# File lib/rubocop/formatter/simple_text_formatter.rb, line 146 def offenses text = pluralize(@offense_count, 'offense', no_for_zero: true) color = @offense_count.zero? ? :green : :red colorize(text, color) end