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

Lint/ToEnumArguments doesn't support anonymous argument forwarding #12143

Closed
inkstak opened this issue Aug 22, 2023 · 0 comments · Fixed by #12145
Closed

Lint/ToEnumArguments doesn't support anonymous argument forwarding #12143

inkstak opened this issue Aug 22, 2023 · 0 comments · Fixed by #12145
Labels

Comments

@inkstak
Copy link

inkstak commented Aug 22, 2023

Expected behavior

Since anonymous arguments forwarding is enforced by Style/ArgumentsForwarding,
the code below should also be validated by Lint/ToEnumArguments

def do_something(**)
  return to_enum(:do_something, **) unless block_given?

  do_something_else
end

Actual behavior

The code return the following issue:

file.rb:10:20: W: Lint/ToEnumArguments: Ensure you correctly provided all the arguments.
            return to_enum(:do_something, **) unless block_given?
                   ^^^^^^^^^^^^^^^^^^^

Steps to reproduce the problem

Create a file with example above, then run bundle exec rubocop --only Lint/ToEnumArguments example.rb

RuboCop version

$ [bundle exec] rubocop -V
1.56.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.1) +server [arm64-darwin22]
  - rubocop-factory_bot 2.23.1
  - rubocop-performance 1.19.0
  - rubocop-rails 2.20.2
  - rubocop-rspec 2.23.2
@inkstak inkstak changed the title Lint/ToEnumArguments doesn't support anonymous argument forwarding Lint/ToEnumArguments doesn't support anonymous argument forwarding Aug 22, 2023
@koic koic added the bug label Aug 22, 2023
koic added a commit to koic/rubocop that referenced this issue Aug 22, 2023
Fixes rubocop#12143.

This PR fixes a false positive for `Lint/ToEnumArguments`
when using anonymous keyword arguments forwarding.
koic added a commit that referenced this issue Aug 22, 2023
…enum_arguments

[Fix #12143] Fix a false positive for `Lint/ToEnumArguments`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants