Skip to content
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

Conversation

kkitadate
Copy link
Contributor

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:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • [-] Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • [-] Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.
  • [-] If this is a new cop, consider making a corresponding update to the Rails Style Guide.

Comment on lines 118 to 119
expect_no_offenses(<<~RUBY)
puts "test #\{123\}. Hey!"
puts "test #{described_class}. Hey!"
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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!"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@kkitadate kkitadate force-pushed the fix-test-case-in-file_path_spec-for-redundant-string-escape branch from db8c22d to c3d9ecf Compare September 29, 2022 14:59
@@ -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!"
Copy link
Member

@koic koic Sep 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<<~'RUBY' can remove the \.

Suggested change
puts "test #\{123\}. Hey!"
puts "test #{123}. Hey!"

Copy link
Contributor Author

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.
@kkitadate kkitadate force-pushed the fix-test-case-in-file_path_spec-for-redundant-string-escape branch from c3d9ecf to 7b07474 Compare September 29, 2022 15:12
@koic koic merged commit 181b497 into rubocop:master Sep 29, 2022
@koic
Copy link
Member

koic commented Sep 29, 2022

👍

@kkitadate kkitadate deleted the fix-test-case-in-file_path_spec-for-redundant-string-escape branch September 29, 2022 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants