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

Style/RedundantReturn cop does not detect any offences #12106

Closed
ydakuka opened this issue Aug 8, 2023 · 2 comments · Fixed by #12108
Closed

Style/RedundantReturn cop does not detect any offences #12106

ydakuka opened this issue Aug 8, 2023 · 2 comments · Fixed by #12108

Comments

@ydakuka
Copy link

ydakuka commented Aug 8, 2023

Actual behavior

I have the following code:

# frozen_string_literal: true

module ApplicationHelper
  def my_method(condition)
    return 'active' if condition
  end
end

I run rubocop and don't get any offences.

ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop app/helpers/application_helper.rb
Inspecting 1 file
.

1 file inspected, no offenses detected

RuboCop version

ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop -V
1.55.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 2.7.8) [x86_64-linux]
  - rubocop-capybara 2.18.0
  - rubocop-factory_bot 2.23.1
  - rubocop-performance 1.18.0
  - rubocop-rails 2.20.2
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.23.0
  - rubocop-thread_safety 0.5.1
@dvandersluis
Copy link
Member

dvandersluis commented Aug 8, 2023

Your code is explicitly an example of a "good" use in the documentation:

# good
def test
  return something if something_else
end

It looks like it was intended to be implemented in the future but never happened. I'll take a look at it now.

koic added a commit to koic/rubocop that referenced this issue Aug 8, 2023
Fixes rubocop#12106.

This PR fixes a false negative for `Style/RedundantReturn`
when returning value with guard clause and `return` is used.
@koic
Copy link
Member

koic commented Aug 8, 2023

I had already opened #12108 as a false negative. Thank you.

bbatsov pushed a commit that referenced this issue Aug 8, 2023
Fixes #12106.

This PR fixes a false negative for `Style/RedundantReturn`
when returning value with guard clause and `return` is used.
waiting-for-dev added a commit to nebulab/solidus that referenced this issue Aug 9, 2023
Rubocop 1.56 fixed a false negative for `Style/RedundantReturn` cop.

See rubocop/rubocop#12106
github-actions bot pushed a commit to solidusio/solidus that referenced this issue Aug 10, 2023
Rubocop 1.56 fixed a false negative for `Style/RedundantReturn` cop.

See rubocop/rubocop#12106

(cherry picked from commit ddba778)
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

Successfully merging a pull request may close this issue.

3 participants