class RuboCop::Formatter::FuubarStyleFormatter
This formatter displays a progress bar and shows details of offenses as soon as they are detected. This is inspired by the Fuubar formatter for RSpec by Jeff Kreeftmeijer. github.com/jeffkreeftmeijer/fuubar
Constants
- RESET_SEQUENCE
Public Instance Methods
count_stats(offenses)
click to toggle source
Calls superclass method
# File lib/rubocop/formatter/fuubar_style_formatter.rb, line 45 def count_stats(offenses) super offenses = offenses.reject(&:corrected?) return if offenses.empty? offenses << @severest_offense if @severest_offense @severest_offense = offenses.max_by(&:severity) end
file_finished(file, offenses)
click to toggle source
# File lib/rubocop/formatter/fuubar_style_formatter.rb, line 34 def file_finished(file, offenses) count_stats(offenses) unless offenses.empty? @progressbar.clear report_file(file, offenses) end with_color { @progressbar.increment } end
progressbar_color()
click to toggle source
# File lib/rubocop/formatter/fuubar_style_formatter.rb, line 65 def progressbar_color if @severest_offense COLOR_FOR_SEVERITY[@severest_offense.severity.name] else :green end end
started(target_files)
click to toggle source
Calls superclass method
# File lib/rubocop/formatter/fuubar_style_formatter.rb, line 14 def started(target_files) super @severest_offense = nil file_phrase = target_files.count == 1 ? 'file' : 'files' # 185/407 files |====== 45 ======> | ETA: 00:00:04 # %c / %C | %w > %i | %e bar_format = " %c/%C #{file_phrase} |%w>%i| %e " @progressbar = ProgressBar.create( output: output, total: target_files.count, format: bar_format, autostart: false ) with_color { @progressbar.start } end
with_color() { || ... }
click to toggle source
# File lib/rubocop/formatter/fuubar_style_formatter.rb, line 55 def with_color if rainbow.enabled output.write colorize('', progressbar_color).chomp(RESET_SEQUENCE) yield output.write RESET_SEQUENCE else yield end end