Class: RuboCop::Formatter::DisabledConfigFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- RuboCop::Formatter::DisabledConfigFormatter
- Defined in:
- lib/rubocop/formatter/disabled_config_formatter.rb
Overview
This formatter displays a YAML configuration file where all cops that detected any offenses are configured to not detect the offense.
Constant Summary collapse
- HEADING =
<<-COMMENTS.strip_indent # This configuration was generated by # `%<command>s` # %<timestamp>susing RuboCop version #{Version.version}. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. COMMENTS
Class Attribute Summary collapse
-
.config_to_allow_offenses ⇒ Object
Returns the value of attribute config_to_allow_offenses.
-
.detected_styles ⇒ Object
Returns the value of attribute detected_styles.
Attributes inherited from BaseFormatter
Instance Method Summary collapse
- #file_finished(file, offenses) ⇒ Object
- #file_started(_file, _file_info) ⇒ Object
- #finished(_inspected_files) ⇒ Object
-
#initialize(output, options = {}) ⇒ DisabledConfigFormatter
constructor
A new instance of DisabledConfigFormatter.
Methods inherited from BaseFormatter
Constructor Details
#initialize(output, options = {}) ⇒ DisabledConfigFormatter
Returns a new instance of DisabledConfigFormatter.
25 26 27 28 29 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 25 def initialize(output, = {}) super @cops_with_offenses ||= Hash.new(0) @files_with_offenses ||= {} end |
Class Attribute Details
.config_to_allow_offenses ⇒ Object
Returns the value of attribute config_to_allow_offenses.
22 23 24 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 22 def config_to_allow_offenses @config_to_allow_offenses end |
.detected_styles ⇒ Object
Returns the value of attribute detected_styles.
22 23 24 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 22 def detected_styles @detected_styles end |
Instance Method Details
#file_finished(file, offenses) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 38 def file_finished(file, offenses) offenses.each do |o| @cops_with_offenses[o.cop_name] += 1 @files_with_offenses[o.cop_name] ||= [] @files_with_offenses[o.cop_name] << file end end |
#file_started(_file, _file_info) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 31 def file_started(_file, _file_info) @exclude_limit_option = @options[:exclude_limit] @exclude_limit = Integer(@exclude_limit_option || RuboCop::Options::DEFAULT_MAXIMUM_EXCLUSION_ITEMS) @show_offense_counts = !@options[:no_offense_counts] end |
#finished(_inspected_files) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 46 def finished(_inspected_files) output.puts format(HEADING, command: command, timestamp: ) # Syntax isn't a real cop and it can't be disabled. @cops_with_offenses.delete('Lint/Syntax') output_offenses puts "Created #{output.path}." end |