Class: Rubocop::Formatter::DisabledConfigFormatter

Inherits:
BaseFormatter
  • Object
show all
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 disabled.

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")

Instance Attribute Summary

Attributes inherited from BaseFormatter

#output

Instance Method Summary collapse

Methods inherited from BaseFormatter

#file_started, #initialize, #started

Constructor Details

This class inherits a constructor from Rubocop::Formatter::BaseFormatter

Instance Method Details

#file_finished(file, offences) ⇒ Object



14
15
16
17
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 14

def file_finished(file, offences)
  @cops_with_offences ||= {}
  offences.each { |o| @cops_with_offences[o.cop_name] = true }
end

#finished(inspected_files) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 19

def finished(inspected_files)
  output.puts HEADING
  @cops_with_offences.keys.sort.each do |cop_name|
    output.puts
    output.puts "#{cop_name}:"
    output.puts '  Enabled: false'
  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