Skip to content

Commit

Permalink
Supress Style/RedundantStringEscape's offenses
Browse files Browse the repository at this point in the history
This commit supresses the following `Style/RedundantStringEscape`'s offenses.

```console
% bundle exec rake
(snip)

Offenses:

spec/rubocop/cop/performance/fixed_size_spec.rb:50:29: C: [Corrected] Style/RedundantStringEscape:
Redundant escape of % inside string literal.
expect_no_offenses("\%Q(\#{foo}).#{method}")
                    ^^
spec/rubocop/cop/performance/fixed_size_spec.rb:54:29: C: [Corrected] Style/RedundantStringEscape:
Redundant escape of % inside string literal.
expect_no_offenses("\%(\#{foo}).#{method}")
                    ^^
spec/rubocop/cop/performance/redundant_split_regexp_argument_spec.rb:66:34: C: [Corrected] Style/RedundantStringEscape:
Redundant escape of % inside string literal.
"foo\\\\\\.bar".split("\\\\\.")
                           ^^
spec/rubocop/cop/performance/string_replacement_spec.rb:47:27: C: [Corrected] Style/RedundantStringEscape:
Redundant escape of % inside string literal.
'abc'.#{method}(\"\#{foo}\", '1')
                ^^
spec/rubocop/cop/performance/string_replacement_spec.rb:47:36: C: [Corrected] Style/RedundantStringEscape:
Redundant escape of % inside string literal.
'abc'.#{method}(\"\#{foo}\", '1')
                         ^^
spec/rubocop/cop/performance/string_replacement_spec.rb:54:32: C: [Corrected] Style/RedundantStringEscape:
Redundant escape of % inside string literal.
'abc'.#{method}('a', \"\#{foo}\")
                     ^^
spec/rubocop/cop/performance/string_replacement_spec.rb:54:41: C: [Corrected] Style/RedundantStringEscape:
Redundant escape of % inside string literal.
'abc'.#{method}('a', \"\#{foo}\")
                              ^^

115 files inspected, 7 offenses detected, 7 offenses corrected
```
  • Loading branch information
koic committed Sep 29, 2022
1 parent 4fb546b commit d5bb1fe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions spec/rubocop/cop/performance/fixed_size_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
end

it "accepts calling #{method} on a %Q string that contains interpolation" do
expect_no_offenses("\%Q(\#{foo}).#{method}")
expect_no_offenses("%Q(\#{foo}).#{method}")
end

it "accepts calling #{method} on a % string that contains interpolation" do
expect_no_offenses("\%(\#{foo}).#{method}")
expect_no_offenses("%(\#{foo}).#{method}")
end

it "accepts calling #{method} on a single quoted string that is assigned to a constant" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
RUBY

expect_correction(<<~RUBY)
"foo\\\\\\.bar".split("\\\\\.")
"foo\\\\\\.bar".split("\\\\.")
RUBY
end

Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/cop/performance/string_replacement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
it 'accepts a pattern with string interpolation' do
expect_no_offenses(<<~RUBY)
foo = 'a'
'abc'.#{method}(\"\#{foo}\", '1')
'abc'.#{method}("\#{foo}", '1')
RUBY
end

it 'accepts a replacement with string interpolation' do
expect_no_offenses(<<~RUBY)
foo = '1'
'abc'.#{method}('a', \"\#{foo}\")
'abc'.#{method}('a', "\#{foo}")
RUBY
end

Expand Down

0 comments on commit d5bb1fe

Please sign in to comment.