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
merged 4 commits into from Jan 2, 2020

Conversation

@Drenmi
Copy link
Collaborator

Drenmi commented Dec 30, 2019

Note!

Not ready until we fix this.

Background

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

def foo(...)
  bar(...)
end

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
@koic

This comment has been minimized.

Copy link
Member

koic commented Dec 30, 2019

Not ready until we fix this.

Parser 2.7.0.1 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

This comment has been minimized.

Copy link
@buehmann

buehmann Dec 30, 2019

Contributor

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 Drenmi:feature/forward-arguments branch from 3a57b3d to 7bcc234 Jan 2, 2020
@Drenmi

This comment has been minimized.

Copy link
Collaborator Author

Drenmi commented Jan 2, 2020

@koic Rebased. 🙏

@bbatsov bbatsov merged commit 2c0eec6 into rubocop-hq:master Jan 2, 2020
25 checks passed
25 checks passed
ci/circleci: cc-setup Your tests passed on CircleCI!
Details
ci/circleci: cc-upload-coverage Your tests passed on CircleCI!
Details
ci/circleci: documentation-checks Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-rubocop Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-spec Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@bbatsov

This comment has been minimized.

Copy link
Collaborator

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
Projects
None yet
4 participants
You can’t perform that action at this time.