rubocop / rubocop

A Ruby static code analyzer and formatter, based on the community Ruby style guide.

Home Page:https://docs.rubocop.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Style/ArgumentsForwarding` enforce anonymous bad autocorrect

janklimo opened this issue · comments

The following code:

    def validators_on(*args)
      [
        super,
        resource_class.validators_on(*args),
        *@auxiliary_resource_classes.map do |klass|
          klass.validators_on(*args)
        end,
      ].flatten
    end
  end

results in invalid autocorrect output with

Style/ArgumentsForwarding:
  UseAnonymousForwarding: true
  Enabled: true

Expected behavior

    def validators_on(*args)
      [
        super,
        resource_class.validators_on(*args),
        *@auxiliary_resource_classes.map do |klass|
          klass.validators_on(*args)
        end,
      ].flatten
    end
  end

Actual behavior

    def validators_on(*)
      [
        super,
        resource_class.validators_on(*),
        *@auxiliary_resource_classes.map do |klass|
          klass.validators_on(*args)
        end,
      ].flatten
    end
  end

*args will no longer be defined.

Steps to reproduce the problem

Example code above.

RuboCop version

1.63.4 (using Parser 3.3.1.0, rubocop-ast 1.31.2, running on ruby 3.3.1) [arm64-darwin23]
  - rubocop-capybara 2.20.0
  - rubocop-factory_bot 2.25.1
  - rubocop-performance 1.20.2
  - rubocop-rails 2.24.0
  - rubocop-rspec 2.27.1