Sha256: 72d52996d6fc6df3c504295ab568706c14d67b3c6148595464372440775e5b8b

Contents?: true

Size: 1.19 KB

Versions: 18

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require 'yaml'
require 'pathname'

module RuboCop
  # A mixin to break up ConfigLoader
  module ConfigLoaderResolver
    def resolve_requires(path, hash)
      config_dir = File.dirname(path)
      Array(hash.delete('require')).each do |r|
        if r.start_with?('.')
          require(File.join(config_dir, r))
        else
          require(r)
        end
      end
    end

    def resolve_inheritance(path, hash)
      base_configs(path, hash['inherit_from']).reverse_each do |base_config|
        base_config.each do |k, v|
          hash[k] = hash.key?(k) ? merge(v, hash[k]) : v if v.is_a?(Hash)
        end
      end
    end

    def resolve_inheritance_from_gems(hash, gems)
      (gems || {}).each_pair do |gem_name, config_path|
        if gem_name == 'rubocop'
          raise ArgumentError,
                "can't inherit configuration from the rubocop gem"
        end

        hash['inherit_from'] = Array(hash['inherit_from'])
        Array(config_path).reverse.each do |path|
          # Put gem configuration first so local configuration overrides it.
          hash['inherit_from'].unshift gem_config_path(gem_name, path)
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/config_loader_resolver.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/config_loader_resolver.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/config_loader_resolver.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/config_loader_resolver.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/config_loader_resolver.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/config_loader_resolver.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/config_loader_resolver.rb
rubocop-0.50.0 lib/rubocop/config_loader_resolver.rb
rubocop-0.49.1 lib/rubocop/config_loader_resolver.rb
rubocop-0.49.0 lib/rubocop/config_loader_resolver.rb
rubocop-0.48.1 lib/rubocop/config_loader_resolver.rb
rubocop-0.48.0 lib/rubocop/config_loader_resolver.rb
rubocop-0.47.1 lib/rubocop/config_loader_resolver.rb
rubocop-0.47.0 lib/rubocop/config_loader_resolver.rb
rubocop-0.46.0 lib/rubocop/config_loader_resolver.rb
rubocop-0.45.0 lib/rubocop/config_loader_resolver.rb
rubocop-0.44.1 lib/rubocop/config_loader_resolver.rb
rubocop-0.44.0 lib/rubocop/config_loader_resolver.rb