Class: RuboCop::Cop::Lint::UnusedMethodArgument

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/lint/unused_method_argument.rb

Instance Method Summary collapse

Instance Method Details

#message(variable) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rubocop/cop/lint/unused_method_argument.rb', line 7

def message(variable)
  message = String.new(
    "ζ*'ヮ')ζ<うっうー!使っていない引数がありますよー `#{variable.name}`!"
  )

  unless variable.keyword_argument?
    message << " もし使わないなら、`_`か`_#{variable.name}`のようにしましょうねー!"
  end

  scope = variable.scope
  all_arguments = scope.variables.each_value.select(&:method_argument?)

  if all_arguments.none?(&:referenced?)
    message << ' 引数がなんでもいいなら、' \
               "メソッド名を `#{scope.name}(*)` に変えてもいいですよー!"
  end

  message
end