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

Autocorrect Failure: Redundant return detected #516

Closed
dlecocq opened this issue Sep 27, 2013 · 2 comments
Closed

Autocorrect Failure: Redundant return detected #516

dlecocq opened this issue Sep 27, 2013 · 2 comments
Assignees

Comments

@dlecocq
Copy link

dlecocq commented Sep 27, 2013

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
@jonas054
Copy link
Collaborator

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.

@ghost ghost assigned jonas054 Sep 27, 2013
@bbatsov
Copy link
Collaborator

bbatsov commented Sep 27, 2013

@jonas054 Autocorrect this to an array as you suggested.

bbatsov added a commit that referenced this issue Sep 28, 2013
[Fix #516] Fix RedundantReturn auto-correction bug.
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

3 participants