lib/rubocop/cop/performance/string_replacement.rb in rubocop-0.42.0 vs lib/rubocop/cop/performance/string_replacement.rb in rubocop-0.43.0
- old
+ new
@@ -158,13 +158,11 @@
klass == :Regexp && REGEXP_CONSTRUCTOR_METHODS.include?(init)
end
def range(node)
- Parser::Source::Range.new(node.source_range.source_buffer,
- node.loc.selector.begin_pos,
- node.source_range.end_pos)
+ range_between(node.loc.selector.begin_pos, node.source_range.end_pos)
end
def replacement_method(method, first_source, second_source)
replacement = if second_source.empty? && first_source.length == 1
DELETE
@@ -190,13 +188,11 @@
def method_suffix(node)
node.loc.end ? node.loc.end.source : ''
end
def remove_second_param(corrector, node, first_param)
- end_range =
- Parser::Source::Range.new(node.source_range.source_buffer,
- first_param.source_range.end_pos,
- node.source_range.end_pos)
+ end_range = range_between(first_param.source_range.end_pos,
+ node.source_range.end_pos)
corrector.replace(end_range, method_suffix(node))
end
end
end