Rubocop: Autocorrect Failure: Redundant `return` detected

Created on 27 Sep 2013  路  2Comments  路  Source: rubocop-hq/rubocop

Distilled from a real world example (https://github.com/seomoz/qless/blob/9e5ef9cae19ef8ba59d0ac51636bf068aa0ff9a1/spec/integration/qless_spec.rb#L2433). If I have:

# foo.rb
# Encoding: utf-8

def foo
  return 1, 2
end

If I then run rubocop -a foo.rb, it generates invalid ruby:

# foo.rb
# Encoding: utf-8

def foo
  1, 2
end

Most helpful comment

Excellent work finding these bugs! I'll take this one too.

I think the auto-correction in this case should produce

# foo.rb
# Encoding: utf-8

def foo
  [1, 2]
end

The other alternative would be to leave it unchanged, but I prefer to change it.

All 2 comments

Excellent work finding these bugs! I'll take this one too.

I think the auto-correction in this case should produce

# foo.rb
# Encoding: utf-8

def foo
  [1, 2]
end

The other alternative would be to leave it unchanged, but I prefer to change it.

@jonas054 Autocorrect this to an array as you suggested.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

deivid-rodriguez picture deivid-rodriguez  路  3Comments

bquorning picture bquorning  路  3Comments

kirrmann picture kirrmann  路  3Comments

cabello picture cabello  路  3Comments

AndreiMotinga picture AndreiMotinga  路  3Comments