Sha256: e773a3e9a309a8cbb6a06f2c17815450e8141280a402ab371d89aac2513512a2

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

# encoding: utf-8
# 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'])
        # Put gem configuration first so local configuration overrides it.
        hash['inherit_from'].unshift gem_config_path(gem_name, config_path)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/rubocop-0.42.0/lib/rubocop/config_loader_resolver.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/rubocop-0.42.0/lib/rubocop/config_loader_resolver.rb
rubocop-0.42.0 lib/rubocop/config_loader_resolver.rb
rubocop-0.41.2 lib/rubocop/config_loader_resolver.rb
rubocop-0.41.1 lib/rubocop/config_loader_resolver.rb
rubocop-0.41.0 lib/rubocop/config_loader_resolver.rb
rubocop-0.40.0 lib/rubocop/config_loader_resolver.rb
rubocop-0.39.0 lib/rubocop/config_loader_resolver.rb