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/RedundantReceiverInWithOptions error #794

Closed
aglushkov opened this issue Sep 27, 2022 · 0 comments · Fixed by #795
Closed

Rails/RedundantReceiverInWithOptions error #794

aglushkov opened this issue Sep 27, 2022 · 0 comments · Fixed by #795
Labels
bug Something isn't working

Comments

@aglushkov
Copy link

Rubocop shows parsing error with such code:

def log(data, **opts)
  if opts[:print]
    print data
  else
    puts data
  end
end

with_options(print: true) do
  data = %w[foo bar].join(',')
  log(data)
end
1 error occurred:
An error occurred while Rails/RedundantReceiverInWithOptions cop was inspecting .../err.rb:11:0.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues

Mention the following information in the issue report:
1.36.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 3.1.2) [x86_64-linux]
undefined method `children' for nil:NilClass

          recv_node && recv_node.children[0] == arg_node.children[0]
                                                        ^^^^^^^^^
rubocop-rails-2.16.1/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb:131:in `same_value?'
rubocop-rails-2.16.1/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb:102:in `block in redundant_receiver?'
rubocop-rails-2.16.1/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb:75:in `block in all_send_nodes_in'
@Darhazer Darhazer transferred this issue from rubocop/rubocop-rspec Sep 27, 2022
@koic koic added the bug Something isn't working label Sep 27, 2022
koic added a commit to koic/rubocop-rails that referenced this issue Sep 27, 2022
…ons`

Fixes rubocop#794.

This PR fixes an error for `Rails/RedundantReceiverInWithOptions`
when calling a method with a receiver in `with_options` without block arguments
@koic koic closed this as completed in #795 Oct 5, 2022
koic added a commit that referenced this issue Oct 5, 2022
…ceiver_in_with_option

[Fix #794] Fix an error for `Rails/RedundantReceiverInWithOptions`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants