Class: RuboCop::Formatter::FuubarStyleFormatter
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
RuboCop::Formatter::ClangStyleFormatter
|
Defined in: | lib/rubocop/formatter/fuubar_style_formatter.rb |
Overview
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. https://github.com/jeffkreeftmeijer/fuubar
Constant Summary
-
RESET_SEQUENCE =
# File 'lib/rubocop/formatter/fuubar_style_formatter.rb', line 12"\e[0m"
::RuboCop::PathUtil
- Included
HIDDEN_FILE_PATTERN, SMART_PATH_CACHE
SimpleTextFormatter
- Inherited
ClangStyleFormatter
- Inherited
Class Method Summary
Instance Attribute Summary
BaseFormatter
- Inherited
Instance Method Summary
- #count_stats(offenses)
- #file_finished(file, offenses)
- #progressbar_color
- #started(target_files)
- #with_color
ClangStyleFormatter
- Inherited
SimpleTextFormatter
- Inherited
#file_finished, #finished, #report_file, #report_summary, #started, #annotate_message, #colored_severity_code, #count_stats, #message |
::RuboCop::PathUtil
- Included
#absolute? | Returns true for an absolute Unix or Windows path. |
#glob? | Returns true for a glob. |
#hidden_dir?, #hidden_file?, #hidden_file_in_not_hidden_dir?, | |
#match_path? | Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity. |
#maybe_hidden_file? | Loose check to reduce memory allocations. |
#relative_path, #smart_path |
Colorizable
- Included
BaseFormatter
- Inherited
#file_finished | Invoked at the end of inspecting each files. |
#file_started | Invoked at the beginning of inspecting each files. |
#finished | Invoked after all files are inspected or interrupted by user. |
#started | Invoked once before any files are inspected. |
Constructor Details
.new(*output) ⇒ FuubarStyleFormatter
# File 'lib/rubocop/formatter/fuubar_style_formatter.rb', line 14
def initialize(*output) @severest_offense = nil super end
Instance Method Details
#count_stats(offenses)
[ GitHub ]# File 'lib/rubocop/formatter/fuubar_style_formatter.rb', line 51
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)
[ GitHub ]# File 'lib/rubocop/formatter/fuubar_style_formatter.rb', line 40
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
[ GitHub ]# File 'lib/rubocop/formatter/fuubar_style_formatter.rb', line 71
def if @severest_offense COLOR_FOR_SEVERITY[@severest_offense.severity.name] else :green end end
#started(target_files)
[ GitHub ]# File 'lib/rubocop/formatter/fuubar_style_formatter.rb', line 20
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 = " %c/%C #{file_phrase} |%w>%i| %e " @progressbar = ProgressBar.create( output: output, total: target_files.count, format: , autostart: false ) with_color { @progressbar.start } end
#with_color
[ GitHub ]# File 'lib/rubocop/formatter/fuubar_style_formatter.rb', line 61
def with_color if rainbow.enabled output.write colorize('', ).chomp(RESET_SEQUENCE) yield output.write RESET_SEQUENCE else yield end end