Class: RuboCop::Formatter::SimpleTextFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- RuboCop::Formatter::SimpleTextFormatter
- Includes:
- Colorizable, PathUtil
- Defined in:
- lib/rubocop/formatter/simple_text_formatter.rb
Overview
A basic formatter that displays only files with offenses. Offenses are displayed at compact form - just the location of the problem and the associated message.
Direct Known Subclasses
Defined Under Namespace
Classes: Report
Constant Summary collapse
- COLOR_FOR_SEVERITY =
{ info: :gray, refactor: :yellow, convention: :yellow, warning: :magenta, error: :red, fatal: :red }.freeze
Constants included from PathUtil
Instance Attribute Summary
Attributes inherited from BaseFormatter
Instance Method Summary collapse
- #file_finished(file, offenses) ⇒ Object
- #finished(inspected_files) ⇒ Object
- #report_file(file, offenses) ⇒ Object
- #report_summary(file_count, offense_count, correction_count, correctable_count) ⇒ Object
- #started(_target_files) ⇒ Object
Methods included from PathUtil
absolute?, glob?, hidden_dir?, hidden_file?, hidden_file_in_not_hidden_dir?, match_path?, maybe_hidden_file?, pwd, relative_path, remote_file?, reset_pwd, smart_path
Methods included from Colorizable
Methods inherited from BaseFormatter
#file_problems, #file_started, #initialize
Constructor Details
This class inherits a constructor from RuboCop::Formatter::BaseFormatter
Instance Method Details
#file_finished(file, offenses) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 27 def file_finished(file, offenses) return if offenses.empty? count_stats(offenses) report_file(file, offenses) end |
#finished(inspected_files) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 34 def finished(inspected_files) report_summary(inspected_files.count, @total_offense_count, @total_correction_count, @total_correctable_count) end |
#report_file(file, offenses) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 41 def report_file(file, offenses) output.puts yellow("== #{smart_path(file)} ==") offenses.each do |o| output.printf( "%<severity>s:%3<line>d:%3<column>d: %<message>s\n", severity: colored_severity_code(o), line: o.line, column: o.real_column, message: (o) ) end end |
#report_summary(file_count, offense_count, correction_count, correctable_count) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 55 def report_summary(file_count, offense_count, correction_count, correctable_count) report = Report.new(file_count, offense_count, correction_count, correctable_count, rainbow, # :safe_autocorrect is a derived option based on several command-line # arguments - see RuboCop::Options#add_autocorrection_options safe_autocorrect: @options[:safe_autocorrect]) output.puts output.puts report.summary end |
#started(_target_files) ⇒ Object
21 22 23 24 25 |
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 21 def started(_target_files) @total_offense_count = 0 @total_correction_count = 0 @total_correctable_count = 0 end |