Class: RuboCop::Formatter::PacmanFormatter
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
RuboCop::Formatter::ClangStyleFormatter
|
Defined in: | lib/rubocop/formatter/pacman_formatter.rb |
Overview
This formatter prints a PACDOT per every file to be analyzed. Pacman will "eat" one PACDOT per file when no offense is detected. Otherwise it will print a Ghost. This is inspired by the Pacman formatter for RSpec by Carlos Rojas. https://github.com/go-labs/rspec_pacman_formatter
Constant Summary
-
FALLBACK_TERMINAL_WIDTH =
# File 'lib/rubocop/formatter/pacman_formatter.rb', line 1480
-
GHOST =
# File 'lib/rubocop/formatter/pacman_formatter.rb', line 15'ᗣ'
-
PACDOT =
# File 'lib/rubocop/formatter/pacman_formatter.rb', line 17Rainbow('•').yellow.bright
-
PACMAN =
# File 'lib/rubocop/formatter/pacman_formatter.rb', line 16Rainbow('ᗧ').yellow.bright
::RuboCop::PathUtil
- Included
HIDDEN_FILE_PATTERN, SMART_PATH_CACHE
SimpleTextFormatter
- Inherited
ClangStyleFormatter
- Inherited
Class Method Summary
Instance Attribute Summary
Instance Method Summary
- #cols
- #file_finished(file, offenses)
- #file_started(_file, _options)
- #next_step(offenses)
- #pacdots(number)
- #started(target_files)
- #step(character)
- #update_progress_line
TextUtil
- Included
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, options = {}) ⇒ PacmanFormatter
# File 'lib/rubocop/formatter/pacman_formatter.rb', line 19
def initialize(output, = {}) super @progress_line = '' @total_files = 0 @repetitions = 0 end
Instance Attribute Details
#progress_line (rw)
[ GitHub ]# File 'lib/rubocop/formatter/pacman_formatter.rb', line 12
attr_accessor :progress_line
Instance Method Details
#cols
[ GitHub ]# File 'lib/rubocop/formatter/pacman_formatter.rb', line 50
def cols @cols ||= begin _height, width = $stdout.winsize width.nil? || width.zero? ? FALLBACK_TERMINAL_WIDTH : width end end
#file_finished(file, offenses)
[ GitHub ]# File 'lib/rubocop/formatter/pacman_formatter.rb', line 37
def file_finished(file, offenses) count_stats(offenses) unless offenses.empty? next_step(offenses) report_file(file, offenses) end
#file_started(_file, _options)
[ GitHub ]#next_step(offenses)
[ GitHub ]# File 'lib/rubocop/formatter/pacman_formatter.rb', line 43
def next_step(offenses) return step('.') if offenses.empty? ghost_color = COLOR_FOR_SEVERITY[offenses.last.severity.name] step(colorize(GHOST, ghost_color)) end
#pacdots(number)
[ GitHub ]# File 'lib/rubocop/formatter/pacman_formatter.rb', line 64
def pacdots(number) @progress_line = PACDOT * number end
#started(target_files)
[ GitHub ]# File 'lib/rubocop/formatter/pacman_formatter.rb', line 26
def started(target_files) super @total_files = target_files.size output.puts "Eating #{pluralize(target_files.size, 'file')}" update_progress_line end
#step(character)
[ GitHub ]# File 'lib/rubocop/formatter/pacman_formatter.rb', line 68
def step(character) regex = /#{Regexp.quote(PACMAN)}|#{Regexp.quote(PACDOT)}/ @progress_line = @progress_line.sub(regex, character) output.printf("%<line>s\r", line: @progress_line) return unless /ᗣ|\./.match?(@progress_line[-1]) @repetitions += 1 output.puts update_progress_line end