Skip to content

Style/MethodDefParentheses does apply when there are special arguments such as ... or **kwargs #14865

@akimd

Description

@akimd

Steps to reproduce the problem

# frozen_string_literal: true

def method _arg: nil, **_opts
  'foo'
end

def on_poison code, ...
  code
end

Expected behavior

It should complain and add parens.

Actual behavior

$ bundle exec rubocop --debug rubocop/method_def_parentheses.rb
For /Users/akim/src/faveod/langeod: configuration from .rubocop.yml
Default configuration from vendor/ruby/3.4.0/gems/rubocop-1.84.1/config/default.yml
Plugin configuration from vendor/ruby/3.4.0/gems/rubocop-minitest-0.38.2/config/default.yml
Plugin configuration from vendor/ruby/3.4.0/gems/rubocop-performance-1.26.1/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning rubocop/method_def_parentheses.rb
Loading cache from /Users/akim/.cache/rubocop_cache/d3c8997f385ebf3bad32d368393535882d0b84e8/6d7a3b621ca1730e04accd938619e4bdab66cfb1/4218559e0c24f758aaefeafbed385e446a7ff8c5
.

1 file inspected, no offenses detected
Finished in 0.10546099953353405 seconds

RuboCop version

$ bundle exec rubocop -V
1.84.1 (using Parser 3.3.10.1, Prism 1.9.0, rubocop-ast 1.49.0, analyzing as Ruby 3.4, running on ruby 3.4.8) [arm64-darwin24]
  - rubocop-minitest 0.38.2
  - rubocop-performance 1.26.1

Thank the team

Thanks to the team!

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