Class: Steep::Diagnostic::Ruby::MethodArityMismatch

Inherits:
Base
  • Object
show all
Defined in:
lib/steep/diagnostic/ruby.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#location, #node

Instance Method Summary collapse

Methods inherited from Base

#detail_lines, #diagnostic_code

Methods included from Helper

#error_name, #full_message

Constructor Details

#initialize(node:, method_type:) ⇒ MethodArityMismatch

Returns a new instance of MethodArityMismatch.



442
443
444
445
446
447
448
449
450
451
# File 'lib/steep/diagnostic/ruby.rb', line 442

def initialize(node:, method_type:)
  args = case node.type
         when :def
           node.children[1]
         when :defs
           node.children[2]
         end #: Parser::AST::Node?
  super(node: node, location: args&.loc&.expression || node.loc.name) # steep:ignore NoMethod
  @method_type = method_type
end

Instance Attribute Details

#method_typeObject (readonly)

Returns the value of attribute method_type.



440
441
442
# File 'lib/steep/diagnostic/ruby.rb', line 440

def method_type
  @method_type
end

Instance Method Details

#header_lineObject



453
454
455
# File 'lib/steep/diagnostic/ruby.rb', line 453

def header_line
  "Method parameters are incompatible with declaration `#{method_type}`"
end