Class: RuboCop::Formatter::FuubarStyleFormatter Private
- Inherits:
-
ClangStyleFormatter
- Object
- BaseFormatter
- SimpleTextFormatter
- ClangStyleFormatter
- RuboCop::Formatter::FuubarStyleFormatter
- Defined in:
- lib/rubocop/formatter/fuubar_style_formatter.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
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
Constant Summary collapse
- RESET_SEQUENCE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"\e[0m"
Constants inherited from ClangStyleFormatter
Constants inherited from SimpleTextFormatter
SimpleTextFormatter::COLOR_FOR_SEVERITY
Constants included from PathUtil
Instance Attribute Summary
Attributes inherited from BaseFormatter
Instance Method Summary collapse
- #count_stats(offenses) ⇒ Object private
- #file_finished(file, offenses) ⇒ Object private
-
#initialize(*output) ⇒ FuubarStyleFormatter
constructor
private
A new instance of FuubarStyleFormatter.
- #progressbar_color ⇒ Object private
- #started(target_files) ⇒ Object private
- #with_color ⇒ Object private
Methods inherited from ClangStyleFormatter
Methods inherited from SimpleTextFormatter
#finished, #report_file, #report_summary
Methods included from PathUtil
absolute?, glob?, hidden_dir?, hidden_file?, hidden_file_in_not_hidden_dir?, match_path?, maybe_hidden_file?, relative_path, smart_path
Methods included from Colorizable
Methods inherited from BaseFormatter
Constructor Details
#initialize(*output) ⇒ FuubarStyleFormatter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of FuubarStyleFormatter.
14 15 16 17 18 |
# File 'lib/rubocop/formatter/fuubar_style_formatter.rb', line 14 def initialize(*output) @severest_offense = nil super end |
Instance Method Details
#count_stats(offenses) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 54 55 56 57 58 59 |
# 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 45 46 47 48 49 |
# 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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 74 75 76 77 |
# 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 64 65 66 67 68 69 |
# 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 |