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 offences are configured to not detect the offence.
Constant Summary collapse
- HEADING =
['# This configuration was generated by `rubocop --auto-gen-config`.', '# The point is for the user to remove these configuration records', '# one by one as the offences are removed from the code base.'] .join("\n")
Class Attribute Summary collapse
-
.config_to_allow_offences ⇒ Object
Returns the value of attribute config_to_allow_offences.
Attributes inherited from BaseFormatter
Instance Method Summary collapse
Methods inherited from BaseFormatter
#file_started, #initialize, #started
Constructor Details
This class inherits a constructor from Rubocop::Formatter::BaseFormatter
Class Attribute Details
.config_to_allow_offences ⇒ Object
Returns the value of attribute config_to_allow_offences.
17 18 19 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 17 def config_to_allow_offences @config_to_allow_offences end |
Instance Method Details
#file_finished(file, offences) ⇒ Object
20 21 22 23 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 20 def file_finished(file, offences) @cops_with_offences ||= {} offences.each { |o| @cops_with_offences[o.cop_name] = true } end |
#finished(inspected_files) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 25 def finished(inspected_files) output.puts HEADING @cops_with_offences.keys.sort.each do |cop_name| output.puts output.puts "#{cop_name}:" cfg = self.class.config_to_allow_offences[cop_name] cfg ||= { 'Enabled' => false } cfg.each { |key, value| output.puts " #{key}: #{value}" } end puts "Created #{output.path}." puts "Run rubocop with --config #{output.path}, or" puts "add inherit_from: #{output.path} in a .rubocop.yml file." end |