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

Lint/LiteralInInterpolation: /te#{'/'}st/ is autocorrected as /te/st/ #13319

Closed
stdedos opened this issue Oct 11, 2024 · 2 comments · Fixed by #13321
Closed

Lint/LiteralInInterpolation: /te#{'/'}st/ is autocorrected as /te/st/ #13319

stdedos opened this issue Oct 11, 2024 · 2 comments · Fixed by #13321
Labels

Comments

@stdedos
Copy link

stdedos commented Oct 11, 2024

Expected behavior

Describe here how you expected RuboCop to behave in this particular situation.

Do nothing?

Actual behavior

Describe here what actually happened.
Please use rubocop --debug when pasting rubocop output as it contains additional information.

$ ./rubocop t.rb -a
t.rb:1:5: F: Lint/Syntax: unknown regexp options: t                             
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)
/te/st/
    ^^
t.rb:1:6: W: [Corrected] Lint/LiteralInInterpolation: Literal interpolation detected.
/te#{'/'}st/
     ^^^
 1/1 file |======================= 100 =======================>| Time: 00:00:01 

1 file inspected, 2 offenses detected, 1 offense corrected

Steps to reproduce the problem

This is extremely important! Providing us with a reliable way to reproduce
a problem will expedite its solution.

require:
  - rubocop-performance

AllCops:
  ActiveSupportExtensionsEnabled: true
  NewCops: enable
  Exclude:
    - 'backend/customer/**/*'

# Disabling because of build issues. See:
# * https://github.com/rubocop/rubocop/discussions/13294
# * https://github.com/rubocop/rubocop/issues/13299
# * https://github.com/rubocop/rubocop/issues/13302
Style/BlockDelimiters:
  Enabled: false

# Minimize git-diff changes, by trying to mimic black:
# https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#how-black-wraps-lines
Layout/MultilineArrayBraceLayout:
  EnforcedStyle: symmetrical

Layout/MultilineArrayLineBreaks:
  Enabled: true

Layout/FirstArrayElementLineBreak:
  Enabled: true

Layout/FirstArrayElementIndentation:
  EnforcedStyle: consistent

Style/TrailingCommaInArrayLiteral:
  EnforcedStyleForMultiline: consistent_comma

Layout/FirstHashElementLineBreak:
  Enabled: true

Style/TrailingCommaInHashLiteral:
  EnforcedStyleForMultiline: consistent_comma

Layout/FirstMethodArgumentLineBreak:
  Enabled: true

Layout/ArgumentAlignment:
  EnforcedStyle: with_first_argument

Style/TrailingCommaInArguments:
  EnforcedStyleForMultiline: consistent_comma

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler.
If you see extension cop versions (e.g. rubocop-performance, rubocop-rspec, and others)
output by rubocop -V, include them as well. Here's an example:

$ [bundle exec] rubocop -V
1.66.1 (using Parser 3.3.5.0, rubocop-ast 1.32.3, analyzing as Ruby 3.3, running on ruby 3.3.5) [x86_64-linux]
  - rubocop-performance 1.22.1
  - rubocop-rspec 3.1.0
@morfenza
Copy link

Hello! Could you please provide further context to what you tried to achieve? I believe this is the expected behaviour either way since it is indeed a literal in interpolation. What is your expected output to the expression you just wrote? (/te#{'/'}st/). I believe that with this info we can think of something!

@stdedos
Copy link
Author

stdedos commented Oct 11, 2024

Well - first of all to not become a syntax error 😓
I guess that is obvious.

idk why it's not marked as bug - I opened one

dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Oct 11, 2024
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Oct 11, 2024
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Oct 11, 2024
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Oct 11, 2024
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Oct 11, 2024
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Oct 11, 2024
bbatsov pushed a commit that referenced this issue Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants