-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Style/StringConcatenation
incorrectly autocorrected the following excerpt of code, causing a syntax error:
autocorrect(node, "File.open(\"#{path}\")" + '.each_line("\n").to_a.join.split(/\n{2,}/).reject { |e| e.empty? }.reverse.map_with_index {|e, i| i == 0 ? e : "#{e}\n\n" }.reverse')
I've isolated it down to what i'm fairly certain is the same issue:
Expected behavior
Style/StringConcatenation
to work properly and not create syntax errors.
Actual behavior
Inspecting 1 file
F
Offenses:
example2.rb:1:10: C: [Corrected] Style/StringConcatenation: Prefer string interpolation to string concatenation.
foo(bar, "\"#{quz}\"" + '')
^^^^^^^^^^^^^^^^^
example2.rb:2:1: F: Lint/Syntax: unexpected token $end
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)
1 file inspected, 2 offenses detected, 1 offense corrected
# the resulting autocorrected code
foo(bar, ""#{quz}"")
Steps to reproduce the problem
# minimized example
foo(bar, "\"#{quz}\"" + '')
RuboCop version
1.80.1 (using Parser 3.3.9.0, rubocop-ast 1.46.0, analyzing as Ruby 2.7, running on ruby 3.4.4) [x86_64-linux-gnu]