Lint: Style/PerlBackrefs

This commit is contained in:
Olle Jonsson 2021-08-16 17:41:28 +02:00 committed by Olle Jonsson
parent f0bc54fecb
commit f1f36be663
3 changed files with 2 additions and 8 deletions

View File

@ -83,9 +83,3 @@ Style/DocumentDynamicEvalDefinition:
- 'lib/faraday/connection.rb'
- 'lib/faraday/options.rb'
# Offense count: 2
# Cop supports --auto-correct.
Style/PerlBackrefs:
Exclude:
- 'lib/faraday/encoders/nested_params_encoder.rb'
- 'spec/support/fake_safe_buffer.rb'

View File

@ -102,7 +102,7 @@ module Faraday
subkeys = key.scan(SUBKEYS_REGEX)
subkeys.each_with_index do |subkey, i|
is_array = subkey =~ /[\[\]]+\Z/
subkey = $` if is_array
subkey = Regexp.last_match.pre_match if is_array
last_subkey = i == subkeys.length - 1
context = prepare_context(context, subkey, is_array, last_subkey)

View File

@ -8,7 +8,7 @@ FakeSafeBuffer = Struct.new(:string) do
def gsub(regex)
string.gsub(regex) do
match, = $&, '' =~ /a/
match, = Regexp.last_match(0), '' =~ /a/
yield(match)
end
end