Class: RuboCop::Formatter::DisabledConfigFormatter Private
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- RuboCop::Formatter::DisabledConfigFormatter
- Includes:
- PathUtil
- Defined in:
- lib/rubocop/formatter/disabled_config_formatter.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
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 constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"# This configuration was generated by\n# `%<command>s`\n# %<timestamp>susing RuboCop version \#{Version.version}.\n# The point is for the user to remove these configuration records\n# one by one as the offenses are removed from the code base.\n# Note that changes in the inspected code, or installation of new\n# versions of RuboCop, may require this file to be generated again.\n"
Constants included from PathUtil
Class Attribute Summary collapse
- .config_to_allow_offenses ⇒ Object private
- .detected_styles ⇒ Object private
Attributes inherited from BaseFormatter
Instance Method Summary collapse
- #file_finished(file, offenses) ⇒ Object private
- #file_started(_file, _file_info) ⇒ Object private
- #finished(_inspected_files) ⇒ Object private
-
#initialize(output, options = {}) ⇒ DisabledConfigFormatter
constructor
private
A new instance of DisabledConfigFormatter.
Methods included from PathUtil
absolute?, glob?, hidden_dir?, hidden_file?, hidden_file_in_not_hidden_dir?, match_path?, maybe_hidden_file?, relative_path, smart_path
Methods inherited from BaseFormatter
Constructor Details
#initialize(output, options = {}) ⇒ DisabledConfigFormatter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 42 43 44 45 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 39 def file_finished(file, offenses) offenses.each do |o| @cops_with_offenses[o.cop_name] += 1 @files_with_offenses[o.cop_name] ||= Set.new @files_with_offenses[o.cop_name] << file end end |
#file_started(_file, _file_info) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 33 def file_started(_file, _file_info) @exclude_limit_option = [:exclude_limit] @exclude_limit = Integer(@exclude_limit_option || RuboCop::Options::DEFAULT_MAXIMUM_EXCLUSION_ITEMS) end |
#finished(_inspected_files) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rubocop/formatter/disabled_config_formatter.rb', line 47 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 |