Class: Ruboclean::PathCleanup
- Inherits:
-
Object
- Object
- Ruboclean::PathCleanup
- Defined in:
- lib/ruboclean/path_cleanup.rb
Overview
Cleans up any ‘Include` or `Exclude` paths that don’t exist. The ‘Include` and `Exclude` paths are relative to the directory where the `.rubocop.yml` file is located. If a path includes a regexp, it’s assumed to be valid. If all entries in ‘Include` or `Exclude` are removed, the entire property is removed. If a Cop gets entirely truncated due to removing all `Includes` and/or `Exclude`, the Cop itself will be removed.
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(configuration_hash, options:) ⇒ PathCleanup
constructor
A new instance of PathCleanup.
Constructor Details
#initialize(configuration_hash, options:) ⇒ PathCleanup
Returns a new instance of PathCleanup.
11 12 13 14 |
# File 'lib/ruboclean/path_cleanup.rb', line 11 def initialize(configuration_hash, options:) @configuration_hash = configuration_hash @options = end |
Instance Method Details
#cleanup ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruboclean/path_cleanup.rb', line 16 def cleanup return configuration_hash if .preserve_paths? configuration_hash.each_with_object({}) do |(top_level_key, top_level_value), hash| result = process_top_level_value(top_level_value) next if Array(result).empty? # No configuration keys left in the cop, remove the entire cop hash[top_level_key] = result end end |