Work around Performance/EndWith false positive

Rubocop warns about "Use String#end_with? instead of a regex match anchored to the end of the string",
it doesn't seem aware of the $` special variable like Performance/RegexpMatch
This commit is contained in:
Bart de Water 2018-07-28 18:36:51 -04:00
parent eb5fea40a4
commit ff9bdc2744
1 changed files with 2 additions and 2 deletions

View File

@ -345,7 +345,7 @@ module ActiveSupport #:nodoc:
end
def require_or_load(file_name, const_path = nil)
file_name = $` if file_name =~ /\.rb\z/
file_name = file_name.chomp(".rb") if file_name.end_with?(".rb")
expanded = File.expand_path(file_name)
return if loaded.include?(expanded)
@ -395,7 +395,7 @@ module ActiveSupport #:nodoc:
# constant paths which would cause Dependencies to attempt to load this
# file.
def loadable_constants_for_path(path, bases = autoload_paths)
path = $` if path =~ /\.rb\z/
path = path.chomp(".rb") if path.end_with?(".rb")
expanded_path = File.expand_path(path)
paths = []