Class: RuboCop::Cop::Lint::ExceptionCall

Inherits:
RuboCop::Cop show all
Defined in:
lib/rubocop/cop/lint/exception_call.rb

Constant Summary collapse

MSG =
'カンマ(,)を忘れていませんか?'.freeze

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/rubocop/cop/lint/exception_call.rb', line 19

def autocorrect(node)
  _receiver, _method_name, *args = *node

  lambda do |corrector|
    corrector.insert_before(loc(args), ',')
  end
end

#on_send(node) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/rubocop/cop/lint/exception_call.rb', line 10

def on_send(node)
  receiver, method_name, *args = *node
  return unless [:raise, :fail].include?(method_name)
  return unless check_receiver(receiver)
  return unless check_args(args)

  add_offense(node, loc(args))
end