Class: RuboCop::Cop::Rbs::MethodSignature

Inherits:
RuboCop::Cop show all
Defined in:
lib/rubocop/cop/rbs/method_signature.rb

Overview

Check for:

  • invalid RBS files;

  • missing RBS method signatures;

  • mismatching RBS method signatures arguments.

Constant Summary collapse

MSG =
'signature mismatch'

Instance Method Summary collapse

Instance Method Details

#on_def(node) ⇒ Object Also known as: on_defs



13
14
15
16
17
18
19
20
21
22
# File 'lib/rubocop/cop/rbs/method_signature.rb', line 13

def on_def(node)
  methods = module_methods(node.parent_module_name)
  return unless methods
  return add_offense(node, message: 'missing signature') unless methods.key?(node.method_name)

  result = check_arity(node, methods[node.method_name].method_types)
  add_offense(node, message: result) if result
rescue RBS::BaseError => e
  add_offense(node, message: "signature error, #{e}")
end