lib/rubocop/git/style_guide.rb in rubocop-git-0.0.5 vs lib/rubocop/git/style_guide.rb in rubocop-git-0.0.6
- old
+ new
@@ -27,11 +27,16 @@
def excluded_file?(file)
config.file_to_exclude?(file.filename)
end
def parse_source(file)
- RuboCop::ProcessedSource.new(file.content)
+ if Gem::Version.new(RuboCop::Version::STRING) < Gem::Version.new('0.36.0')
+ RuboCop::ProcessedSource.new(file.content, file.filename)
+ else
+ RuboCop::ProcessedSource.new(file.content,
+ target_ruby_version, file.filename)
+ end
end
def config
if @config.nil?
config = RuboCop::ConfigLoader.configuration_from_file(@config_file)
@@ -57,9 +62,24 @@
override_config.add_missing_namespaces
override_config.make_excludes_absolute
override_config
else
{}
+ end
+ end
+
+ def target_ruby_version
+ @target ||= begin
+ target = config['AllCops'] && config['AllCops']['TargetRubyVersion']
+
+ if !target || !RuboCop::Config::KNOWN_RUBIES.include?(target)
+ fail ValidationError, "Unknown Ruby version #{target.inspect} found " \
+ 'in `TargetRubyVersion` parameter (in ' \
+ "#{loaded_path}).\nKnown versions: " \
+ "#{RuboCop::Config::KNOWN_RUBIES.join(', ')}"
+ end
+
+ target
end
end
end
end