New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix test case in file_path_spec.rb for Style/RedundantStringEscape
#798
Fix test case in file_path_spec.rb for Style/RedundantStringEscape
#798
Conversation
expect_no_offenses(<<~RUBY) | ||
puts "test #\{123\}. Hey!" | ||
puts "test #{described_class}. Hey!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, but can you tweak it as follows?
- expect_no_offenses(<<~RUBY)
- puts "test #\{123\}. Hey!"
+ expect_no_offenses(<<~'RUBY')
+ puts "test #{123}. Hey!"
RUBY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I did at first, but it fails with Lint/LiteralInInterpolation
.
So it seems that the inside of #{}
must be some variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the heredoc identifier from <<~RUBY
to <<~'RUBY'
would solve the issue.
@@ -245,7 +245,7 @@ | |||
context 'when string contains an interpolation followed by a period' do | |||
it 'does not register an offense' do | |||
expect_no_offenses(<<~RUBY) | |||
puts "test #\{123\}. Hey!" | |||
puts "test #{described_class}. Hey!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
db8c22d
to
c3d9ecf
Compare
@@ -115,7 +115,7 @@ | |||
|
|||
context 'when string contains an interpolation followed by a period' do | |||
it 'does not register an offense' do | |||
expect_no_offenses(<<~RUBY) | |||
expect_no_offenses(<<~'RUBY') | |||
puts "test #\{123\}. Hey!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<<~'RUBY'
can remove the \
.
puts "test #\{123\}. Hey!" | |
puts "test #{123}. Hey!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I fixed it.
CI seems to have failed because rubocop/rubocop#11002 was merged (e.g. rubocop@2723be4) This commit is for fixing it.
c3d9ecf
to
7b07474
Compare
👍 |
CI seems to have failed because rubocop/rubocop#11002 was merged. (e.g. 2723be4)
This commit is for fixing it.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.