Module: NdrDevSupport::Rubocop::Inject

Defined in:
lib/ndr_dev_support/rubocop/inject.rb

Overview

Following approach of rubocop-hq/rubocop-extension-generator, monkey-patch in default configuration.

Class Method Summary collapse

Class Method Details

.defaults!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ndr_dev_support/rubocop/inject.rb', line 16

def self.defaults!
  root = Pathname.new(__dir__).parent.parent.parent.expand_path
  path = root.join('config', 'rubocop', 'ndr.yml').to_s

  # Whereas by default, the raw YAML would be processed, we pass
  # through the ConfigLoader fully - this ensures `require` and
  # `inherit_from` statements are properly evaluated.
  #
  # PR at rubocop-hq/rubocop-extension-generator/pull/9
  #
  config = ::RuboCop::ConfigLoader.load_file(path)
  puts "configuration from \#{path}" if ::RuboCop::ConfigLoader.debug?

  config = ::RuboCop::ConfigLoader.merge_with_default(config, path)
  ::RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
end