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

Rails/SaveBang does not detect implict return when there are multiple lines in the method #1379

Open
maser opened this issue Oct 18, 2024 · 0 comments

Comments

@maser
Copy link

maser commented Oct 18, 2024

Rails/SaveBang does not detect an implicit return when the method has multiple lines.


Expected behavior

With the default configuration for Rails/SaveBang (AllowImplicitReturn: true) I expect the following to not generate an offense:

def foo
  bar

  object.save
end

The #save call is the last expression in the method and its return value will be returned by it.

Actual behavior

I get a Rails/SaveBang offense reported for object.save.

Steps to reproduce the problem

I made the tests for Rails/SaveBang use methods/blocks with multiple lines and they fail: maser@7e8839a

RuboCop version

I noticed it in 2.26.2 and based the above commit on current master.

$ rubocop -V
1.66.1 (using Parser 3.3.5.0, rubocop-ast 1.32.3, running on ruby 3.3.4) [x86_64-linux]
  - rubocop-capybara 2.21.0
  - rubocop-performance 1.22.1
  - rubocop-rails 2.26.2
  - rubocop-rspec 3.1.0
  - rubocop-rspec_rails 2.30.0
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

1 participant