You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While examining the code for this rule, I noticed that the logic for detecting line continuations might mistakenly identify certain cases as such.
In the dstr node type, lines ending with a backslash are flagged. However, multiline single-quoted strings, also parsed as this node type, are mistakenly flagged if they end with a backslash.
Here's a code example:
puts'"this text is too" \" long"'
Expected behavior
No offences for Layout/LineContinuationLeadingSpace should arise.
Actual behavior
An incorrect offence is reported as follows:
example.rb:2:2: C: [Correctable] Layout/LineContinuationLeadingSpace: Move leading spaces to the end of the previous line.
" long"'
^
When applying auto-correction with the -a option, it incorrectly alters the code's meaning as shown below:
puts'"this text is too " \"long"'
Steps to reproduce the problem
Save the following code in a file named example.rb
puts'"this text is too" \" long"'
Run bundle exec rubocop --only=Layout/LineContinuationLeadingSpace example.rb
…LeadingSpace`
Fixesrubocop#12138.
This PR fixes a false positive for `Layout/LineContinuationLeadingSpace`
when a backslash is part of a multiline string literal.
While examining the code for this rule, I noticed that the logic for detecting line continuations might mistakenly identify certain cases as such.
In the
dstr
node type, lines ending with a backslash are flagged. However, multiline single-quoted strings, also parsed as this node type, are mistakenly flagged if they end with a backslash.Here's a code example:
Expected behavior
No offences for
Layout/LineContinuationLeadingSpace
should arise.Actual behavior
An incorrect offence is reported as follows:
When applying auto-correction with the
-a
option, it incorrectly alters the code's meaning as shown below:Steps to reproduce the problem
bundle exec rubocop --only=Layout/LineContinuationLeadingSpace example.rb
RuboCop version
The text was updated successfully, but these errors were encountered: