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
It removes unrelated code block, resulting in code with syntax error. See below.
Steps to reproduce the problem
$ cat <<EOF > foo.rb
class Foo
def value
if @params
case @params[:x]
when 'a'
'b'
else
nil
end
else
'c'
end
end
end
EOF
$ rubocop foo.rb --auto-correct foo.rb
Inspecting 1 file
E
Offenses:
foo.rb:7:7: C: [Corrected] Style/EmptyElse: Redundant else-clause.
else
^^^^
foo.rb:10:1: E: Lint/Syntax: unexpected token $end
(Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
1 file inspected, 2 offenses detected, 1 offense corrected
$ cat foo.rb
class Foo
def value
if @params
case @params[:x]
when 'a'
'b'
end
end
end
$ ruby foo.rb
foo.rb:9: syntax error, unexpected end-of-input, expecting keyword_end
RuboCop version
Include the output of rubocop -V. Here's an example:
Expected behavior
It only removes the redundant else-clause.
Actual behavior
It removes unrelated code block, resulting in code with syntax error. See below.
Steps to reproduce the problem
RuboCop version
Include the output of
rubocop -V
. Here's an example:The text was updated successfully, but these errors were encountered: