Skip to content

Style/ArgumentsForwarding drops arguments #13105

@akimd

Description

@akimd

On this input (which was already tweaked by RuboCop):

def parens(**kwargs, &)
  surround('(', ')', **kwargs, &)
end

auto-correct drops the arguments.


Expected behavior

def parens(...)
  surround('(', ')', ...)
end

Actual behavior

def parens(...)
  surround(...)
end

Steps to reproduce the problem

$ cat rubocop.rb
def parens(**kwargs, &)
  surround('(', ')', **kwargs, &)
end
$ bundle exec rubocop -x --only Style/ArgumentsForwarding rubocop.rb
Inspecting 1 file
C

Offenses:

rubocop.rb:1:12: C: [Corrected] Style/ArgumentsForwarding: Use shorthand syntax ... for arguments forwarding.
def parens(**kwargs, &)
           ^^^^^^^^^^^
rubocop.rb:2:12: C: [Corrected] Style/ArgumentsForwarding: Use shorthand syntax ... for arguments forwarding.
  surround('(', ')', **kwargs, &)
           ^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 2 offenses detected, 2 offenses corrected
$ cat rubocop.rb
def parens(...)
  surround(...)
end

RuboCop version

$ bundle exec rubocop -V
1.65.1 (using Parser 3.3.4.2, rubocop-ast 1.32.0, running on ruby 3.3.4) [arm64-darwin23]
  - rubocop-performance 1.21.1

I have:

AllCops:
  TargetRubyVersion: "3.1"

but nothing specified for Style/ArgumentsForwarding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy