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 =
['# This configuration was generated by', '# `%s`', "# on #{Time.now} using 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.'] .join("\n")
- COPS =
Cop::Cop.registry.to_h
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.
27 28 29 30 31 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 27 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.
24 25 26 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 24 def config_to_allow_offenses @config_to_allow_offenses end |
.detected_styles ⇒ Object
Returns the value of attribute detected_styles.
24 25 26 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 24 def detected_styles @detected_styles end |
Instance Method Details
#file_finished(file, offenses) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 41 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
33 34 35 36 37 38 39 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 33 def file_started(_file, _file_info) @exclude_limit_option = @options[:exclude_limit] @exclude_limit = ( @exclude_limit_option || RuboCop::Options::DEFAULT_MAXIMUM_EXCLUSION_ITEMS).to_i @show_offense_counts = !@options[:no_offense_counts] end |
#finished(_inspected_files) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 49 def finished(_inspected_files) output.puts HEADING % command # 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 |