Class: RuboCop::Cop::Legion::Framework::NoUnderscorePrefixedKwargs

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/legion/framework/no_underscore_prefixed_kwargs.rb

Overview

Bans underscore-prefixed keyword arguments and ‘**_rest`/`**_` splat parameters in method definitions. The N×N routing design requires explicit kwarg signatures: required → plain kwarg, optional → defaulted kwarg, passthrough → `**opts` at the end.

Examples:

# bad
def foo(_bar:); end
def foo(**_rest); end
def foo(**_); end

# good
def foo(bar:); end
def foo(bar: nil); end
def foo(**opts); end

Constant Summary collapse

MSG_KWARG =
'Underscore-prefixed kwarg `%<name>s` is not allowed. ' \
'Use plain kwarg (required), defaulted kwarg (optional), ' \
'or `**opts` for passthrough.'
MSG_SPLAT =
'Underscore-prefixed kwarg splat `%<name>s` is not allowed. ' \
'Use `**opts` for passthrough.'

Instance Method Summary collapse

Instance Method Details

#on_def(node) ⇒ Object



31
32
33
# File 'lib/rubocop/cop/legion/framework/no_underscore_prefixed_kwargs.rb', line 31

def on_def(node)
  check_params(node)
end

#on_defs(node) ⇒ Object



35
36
37
# File 'lib/rubocop/cop/legion/framework/no_underscore_prefixed_kwargs.rb', line 35

def on_defs(node)
  check_params(node)
end