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

[Fix #7602] Handle Ruby 2.7 forward arguments properly #7605

merged 4 commits into from Jan 2, 2020


Copy link

@Drenmi Drenmi commented Dec 30, 2019


Not ready until we fix this.


In Ruby 2.7, a new argument forwarding syntax was introduced. It looks like this:

def foo(...)

This resulted in some unexpected breakage of some of our cops.

What is this fix?

All 2.7 node types have been added to the node traversal class, courtesy of @buehmann.

The biggest change is the introduction of a ForwardArgsNode extension. This allows forward arguments to be handled polymorphically with other argument types. This fixes the majority of the errors.

Additionally, the Naming/MethodParameterName cop has been made aware of forward arguments, so that it does not complain that ... is not a good name.

Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@Drenmi Drenmi changed the title Handle Ruby 2.7 forward arguments properly [Fix #7602] Handle Ruby 2.7 forward arguments properly Dec 30, 2019
Copy link

@koic koic commented Dec 30, 2019

Not ready until we fix this.

Parser has been released and #7597 workaround has been fixed by #7606. Could you rebase with the latest master branch?

match_with_lvasgn begin kwbegin return
in_match case_match in_pattern match_alt
match_as array_pattern array_pattern_with_tail
hash_pattern const_pattern].freeze
Copy link

@buehmann buehmann Dec 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that the traversal methods generated via MANY_CHILD_NODES assume that every child node exists (i.e. is not nil). That is not true for in_pattern nodes, for example. So we need to review those types more carefully.

@Drenmi Drenmi force-pushed the feature/forward-arguments branch from 3a57b3d to 7bcc234 Compare Jan 2, 2020
Copy link
Collaborator Author

@Drenmi Drenmi commented Jan 2, 2020

@koic Rebased. 🙏

@bbatsov bbatsov merged commit 2c0eec6 into rubocop:master Jan 2, 2020
25 checks passed
Copy link

@bbatsov bbatsov commented Jan 2, 2020

I'll likely cut a new release tomorrow or on Monday. There are a few more PRs I'd like to include it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants