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/LineEndConcatenation breaks code #3063

Closed
ptarjan opened this issue Apr 20, 2016 · 0 comments
Closed

Style/LineEndConcatenation breaks code #3063

ptarjan opened this issue Apr 20, 2016 · 0 comments

Comments

@ptarjan
Copy link
Contributor

ptarjan commented Apr 20, 2016

Expected behavior

$ cat /tmp/a.rb
'a' + \
  'b'
$ rubocop /tmp/a.rb -a
...
$ cat /tmp/a.rb
'a' \
  'b'
$ ruby /tmp/a.rb
$

Actual behavior

$ cat /tmp/a.rb
'a' + \
  'b'
$ rubocop /tmp/a.rb -a
Inspecting 1 file
E

Offenses:

/tmp/a.rb:1:5: C: [Corrected] Use \ instead of + or << to concatenate those strings.
'a' + \
    ^
/tmp/a.rb:1:5: E: bare backslash only allowed before newline
(Using Ruby 2.0 parser; configure using TargetRubyVersion parameter, under AllCops)
'a' \\
    ^

1 file inspected, 2 offenses detected, 1 offense corrected
$ cat /tmp/a.rb
'a' \\
  'b'
$ ruby /tmp/a.rb
/tmp/a.rb:1: syntax error, unexpected $undefined, expecting end-of-input
'a' \\
     ^
$

Steps to reproduce the problem

See my /tmp/a.rb

RuboCop version

$ rubocop -V
0.39.0 (using Parser 2.3.0.7, running on ruby 2.1.2 x86_64-darwin15.0)
jonas054 added a commit to jonas054/rubocop that referenced this issue May 1, 2016
Take care not to create a double backslash (a syntax error)
when auto-correcting a + used for string concatenation into
a backslash.

The reporting of the offense remains the same, i.e., no
special message for "you already have a backslash, just
remove the +".
@bbatsov bbatsov closed this as completed in 0bca541 May 1, 2016
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
…op#3098)

Take care not to create a double backslash (a syntax error)
when auto-correcting a + used for string concatenation into
a backslash.

The reporting of the offense remains the same, i.e., no
special message for "you already have a backslash, just
remove the +".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant