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

Style/RedundantRegexpArgument uses double quotes #13099

Closed
akimd opened this issue Aug 8, 2024 · 1 comment · Fixed by #13102
Closed

Style/RedundantRegexpArgument uses double quotes #13099

akimd opened this issue Aug 8, 2024 · 1 comment · Fixed by #13102

Comments

@akimd
Copy link

akimd commented Aug 8, 2024

That cops performs the conversion to string, but uses double quotes when single quotes would suffice, so it fires Style/StringLiterals.

         res <<
           if s.scan(/\\u(\h{4})/)
             "\\u{#{s.captures.first}}"
-          elsif s.scan(/\\#/)
+          elsif s.scan("\\#")
             # Unescape '#', which inspect escaped.
             '#'
           elsif s.scan(/\\./)
             s.matched
-          elsif s.scan(/\$/)
+          elsif s.scan("$")
             # Escape interpolation of variables.
             '\\$'
           else

Expected behavior

Use single quotes by default, or whatever Style/StringLiterals was configured for.

Actual behavior

See above the result of bundle exec rubocop -x --only Style/RedundantRegexpArgument.

Steps to reproduce the problem

See above.

RuboCop version

$ bundle exec rubocop -V
1.65.1 (using Parser 3.3.4.2, rubocop-ast 1.32.0, running on ruby 3.3.4) [arm64-darwin23]
koic added a commit to koic/rubocop that referenced this issue Aug 8, 2024
…hes`

Fixes rubocop#13099.

This PR fixes an error for `Style/IdenticalConditionalBranches`
when handling empty case branches.
@akimd
Copy link
Author

akimd commented Aug 8, 2024

Man, you are fast...

koic added a commit to koic/rubocop that referenced this issue Aug 8, 2024
…`EnforcedStyle` of `Style/StringLiterals`

Fixes rubocop#13099.

This PR makes `Style/RedundantRegexpArgument` respect the `EnforcedStyle` of `Style/StringLiterals`.
Also, combine the way to get the `EnforcedStyle` from `Style/StringLiterals` into `StringLiteralHelp`.
koic added a commit to koic/rubocop that referenced this issue Aug 8, 2024
…`EnforcedStyle` of `Style/StringLiterals`

Fixes rubocop#13099.

This PR makes `Style/RedundantRegexpArgument` respect the `EnforcedStyle` of `Style/StringLiterals`.
Also, combine the way to get the `EnforcedStyle` from `Style/StringLiterals` into `StringLiteralHelp`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants