lib/rubocop/config_loader.rb in rubocop-0.42.0 vs lib/rubocop/config_loader.rb in rubocop-0.43.0
- old
+ new
@@ -31,23 +31,24 @@
end
def load_file(path)
path = File.absolute_path(path)
hash = load_yaml_configuration(path)
-
- resolve_inheritance_from_gems(hash, hash.delete('inherit_gem'))
- resolve_inheritance(path, hash)
- resolve_requires(path, hash)
-
- hash.delete('inherit_from')
config = Config.new(hash, path)
config.deprecation_check do |deprecation_message|
warn("#{path} - #{deprecation_message}")
end
config.add_missing_namespaces
+
+ resolve_inheritance_from_gems(config, config.delete('inherit_gem'))
+ resolve_inheritance(path, config)
+ resolve_requires(path, config)
+
+ config.delete('inherit_from')
+
config.validate
config.make_excludes_absolute
config
end
@@ -138,29 +139,30 @@
Hash[config.map { |cop, params| [cop, yield(params)] }]
end
def load_yaml_configuration(absolute_path)
yaml_code = IO.read(absolute_path, encoding: 'UTF-8')
- hash = yaml_safe_load(yaml_code) || {}
+ hash = yaml_safe_load(yaml_code, absolute_path) || {}
puts "configuration from #{absolute_path}" if debug?
unless hash.is_a?(Hash)
raise(TypeError, "Malformed configuration in #{absolute_path}")
end
hash
end
- def yaml_safe_load(yaml_code)
+ def yaml_safe_load(yaml_code, filename)
if YAML.respond_to?(:safe_load) # Ruby 2.1+
if defined?(SafeYAML) && SafeYAML.respond_to?(:load)
- SafeYAML.load(yaml_code, nil, whitelisted_tags: %w(!ruby/regexp))
+ SafeYAML.load(yaml_code, filename,
+ whitelisted_tags: %w(!ruby/regexp))
else
- YAML.safe_load(yaml_code, [Regexp])
+ YAML.safe_load(yaml_code, [Regexp], [], false, filename)
end
else
- YAML.load(yaml_code)
+ YAML.load(yaml_code, filename)
end
end
def gem_config_path(gem_name, relative_config_path)
spec = Gem::Specification.find_by_name(gem_name)