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

Layout/LineEndStringConcatenationIndentation: false positive offense when no backslashes used #9905

Closed
nandahkrishna opened this issue Jul 2, 2021 · 0 comments
Assignees
Labels

Comments

@nandahkrishna
Copy link

The Layout/LineEndStringConcatenationIndentation cop shows a false positive offense even when no backslashes are used to concatenate strings, such as in the example below. (rubocop -d output is provided below in the template.)

➜ bat test.rb
───────┬──────────────────────────────────────────────────────────────────────────────────
       │ File: test.rb
───────┼──────────────────────────────────────────────────────────────────────────────────
   1   │ text = 'offense'
   2   │ puts 'This probably should not be '"an #{text}"
───────┴──────────────────────────────────────────────────────────────────────────────────

Expected behavior

I would expect the example provided above to not be an offense (with respect to the Layout/LineEndStringConcatenationIndentation cop).

Actual behavior

An offense was shown.

➜ rubocop --only Layout/LineEndStringConcatenationIndentation -d -- test.rb
For /Users/username/Downloads: Default configuration from /Users/username/.gem/ruby/3.0.0/gems/rubocop-1.18.2/config/default.yml
Inspecting 1 file
Scanning /Users/username/Downloads/test.rb
Loading cache from /Users/username/.cache/rubocop_cache/df3a019f8c749a80df8ba46ae487e69edc99342c/43966e1a2abd4a0e4fde78de3cedb433c66f58dd/4c712b4f334e7a6b8113a19a6ecffeed0f23db43
C

Offenses:

test.rb:2:36: C: Layout/LineEndStringConcatenationIndentation: Align parts of a string concatenated with backslash.
puts 'This probably should not be '"an #{text}"
                                   ^^^^^^^^^^^^

1 file inspected, 1 offense detected
Finished in 0.10224999999627471 seconds

Steps to reproduce the problem

  1. Create a test .rb file similar to the example provided (with string concatenation that does not use backslashes to span multiple lines).
  2. Run rubocop --only Layout/LineEndStringConcatenationIndentation -d -- test.rb.

RuboCop version

➜ rubocop -V
1.18.2 (using Parser 3.0.1.1, rubocop-ast 1.7.0, running on ruby 3.0.1 x86_64-darwin20)
@koic koic added the bug label Jul 3, 2021
@jonas054 jonas054 self-assigned this Jul 4, 2021
@koic koic closed this as completed in 98a5a12 Jul 4, 2021
koic added a commit that referenced this issue Jul 4, 2021
…nIndentation_bug

[Fix #9905] Fix single line concatenation false positive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants