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

Add BlockNode#{first,last}_argument helpers #270

Merged
merged 2 commits into from Oct 26, 2023

Conversation

sambostock
Copy link
Contributor

These methods allow more consistent use of first_argument and last_argument across more node types.

The motivation for this PR is to allow for an InternalAffairs/NodeFirstArgument cop to enforce node.arguments.first and node.arguments[0] be replaced with node.first_argument. For this to be possible, we need to extend first_argument to other node types, since the cop can't statically know what the node type is to determine if the method exists or not.

@sambostock
Copy link
Contributor Author

This CI failure seems unrelated:

spec/rubocop/ast/rubocop_compatibility_spec.rb:3:1: C: RSpec/FilePath: Spec path should end with rubocop/ast/rubo_cop_compatibility*_spec.rb.
RSpec.describe RuboCop::AST::RuboCopCompatibility do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@koic
Copy link
Member

koic commented Oct 25, 2023

This CI failure seems unrelated:

JFYI, that offense has been suppressed in the master branch.

These methods allow more consistent use of `first_argument` and
`last_argument` across more node types.
@sambostock
Copy link
Contributor Author

Thanks, @koic. I've rebased, and also extracted the typo fix to #271.

@marcandre marcandre merged commit 737c624 into rubocop:master Oct 26, 2023
19 checks passed
@marcandre
Copy link
Contributor

Nice, thank you

@marcandre
Copy link
Contributor

Released as 1.30.0

@sambostock sambostock deleted the first-argument branch October 27, 2023 18:36
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

Successfully merging this pull request may close these issues.

None yet

3 participants