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 #11089] Fix an error for Style/RedundantStringEscape
when using character literals (e.g. ?a
)
#11090
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bbatsov
reviewed
Oct 20, 2022
ydah
changed the title
[Fix #11089] Fix an error for
[Fix #11089] Fix an error for Oct 20, 2022
Style/RedundantStringEscape
when use string literal ?a
Style/RedundantStringEscape
when use string literal specify one character after ?
Thank you so much. I updated this PR. |
bbatsov
reviewed
Oct 20, 2022
@@ -279,6 +279,14 @@ def wrap(contents) | |||
end | |||
end | |||
|
|||
context 'when string literal specify one character after `?`' do |
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.
I'd shorten this to "when using character literals (e.g. ?a)"
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.
Thank you so much. I updated this PR.
ydah
changed the title
[Fix #11089] Fix an error for
[Fix #11089] Fix an error for Oct 20, 2022
Style/RedundantStringEscape
when use string literal specify one character after ?
Style/RedundantStringEscape
when using character literals (e.g. ?a)
ydah
changed the title
[Fix #11089] Fix an error for
[Fix #11089] Fix an error for Oct 20, 2022
Style/RedundantStringEscape
when using character literals (e.g. ?a)Style/RedundantStringEscape
when using character literals (e.g. ?a
)
koic
reviewed
Oct 21, 2022
…en using character literals (e.g. `?a`) Fix: rubocop#11089
8 tasks
koic
added a commit
to koic/rubocop
that referenced
this pull request
Oct 21, 2022
This PR fixes the following error for `Style/RedundantStringEscape` cop when using `?\n` string character literal. ```console % cat example.rb ?\n % bundle exec rubocop --only Style/RedundantStringEscape -d (snip) An error occurred while Style/RedundantStringEscape cop was inspecting /Users/koic/src/github.com/koic/rubocop-issues/11090/example.rb:1:0. undefined method `source' for nil:NilClass delimiters = [node.loc.begin.source[-1], node.loc.end.source[0]] ^^^^^^^ /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_string_escape.rb:162:in `delimiter?' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_string_escape.rb:110:in `single_quoted?' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_string_escape.rb:103:in `interpolation_not_enabled?' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_string_escape.rb:85:in `allowed_escape?' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_string_escape.rb:51:in `block in on_str' ``` Similar case to rubocop#11089, but not resolved by rubocop#11090. It also removes a bit of unnecessary implementation logic I found.
bbatsov
pushed a commit
that referenced
this pull request
Oct 21, 2022
This PR fixes the following error for `Style/RedundantStringEscape` cop when using `?\n` string character literal. ```console % cat example.rb ?\n % bundle exec rubocop --only Style/RedundantStringEscape -d (snip) An error occurred while Style/RedundantStringEscape cop was inspecting /Users/koic/src/github.com/koic/rubocop-issues/11090/example.rb:1:0. undefined method `source' for nil:NilClass delimiters = [node.loc.begin.source[-1], node.loc.end.source[0]] ^^^^^^^ /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_string_escape.rb:162:in `delimiter?' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_string_escape.rb:110:in `single_quoted?' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_string_escape.rb:103:in `interpolation_not_enabled?' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_string_escape.rb:85:in `allowed_escape?' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/redundant_string_escape.rb:51:in `block in on_str' ``` Similar case to #11089, but not resolved by #11090. It also removes a bit of unnecessary implementation logic I found.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: #11089
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.