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 #11123 ] Fix auto correction bug for Style/StringLiterals #11144
[Fix #11123 ] Fix auto correction bug for Style/StringLiterals #11144
Conversation
@@ -93,7 +93,7 @@ def correct_quotes(str) | |||
end | |||
|
|||
# The conversion process doubles escaped slashes, so they have to be reverted | |||
correction.gsub('\\\\', '\\') | |||
correction.gsub('\\\\', '\\').gsub('\"', '"') |
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.
Can you add a test for the change?
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 change was made to keep this test passing. It was the only one to fail after the change was made in lib/rubocop/cop/util.rb
This looks good to me. Can you add a changelog entry? Please see the end of the PR check items for details. |
@si-lens ping :-) |
94b5862
to
7facde9
Compare
Oh right, forgot about it! |
@@ -0,0 +1 @@ | |||
* [#11123](https://github.com/rubocop/rubocop/issues/11123): Fix autocorrection bug for `Style/StringLiterals` when using multiple escape characters. ([@si-lens][]) |
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.
CI is failing. Can you insert the newline to make the test below pass?
% bundle exec rspec spec/project_spec.rb
(snip)
Failures:
1) RuboCop Project Changelog future entries For /home/circleci/project/spec/../changelog/fix_auto_correction_bug_for_string_literals.md has newline at end of file
Failure/Error: expect(changelog.end_with?("\n")).to be true
7facde9
to
45da59a
Compare
Thanks! |
Fix: #11123
Before:
was corrected to:
These two strings are not the same.
After my changes it should result in correct string:
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.