class Rubocop::DefinitionValidator::Message

Public Class Methods

new(method) click to toggle source

@param [ChangedMethod] method

# File lib/rubocop/definition_validator/message.rb, line 3
def initialize(method)
  @method = method
end

Public Instance Methods

of(reason, *args) click to toggle source

@param [Symbol] reason

# File lib/rubocop/definition_validator/message.rb, line 8
def of(reason, *args)
  __send__(reason, *args) + suffix
end

Private Instance Methods

kwparam_not_found(not_founds) click to toggle source

@param [Array<String>] not_founds

# File lib/rubocop/definition_validator/message.rb, line 52
def kwparam_not_found(not_founds)
  "The following keyword parameters are required. But not received. [#{not_founds.join(', ')}]"
end
kwparam_required() click to toggle source
# File lib/rubocop/definition_validator/message.rb, line 42
def kwparam_required
  "Keyword params is required."
end
kwparam_should_be_hash(got) click to toggle source

@param [String] got

# File lib/rubocop/definition_validator/message.rb, line 47
def kwparam_should_be_hash(got)
  "Keyword params should be a Hash. But got #{got}"
end
method_name() click to toggle source

@return [Proc]

# File lib/rubocop/definition_validator/message.rb, line 16
def method_name
  "#{@method.removed.name} is undefined. Did you mean? #{@method.added.name}"
end
not_enough_normal_after_rest_arguments(given, expected) click to toggle source

@param [Integer] given given args size. @param [Integer] expected expected args size. @return [Proc]

# File lib/rubocop/definition_validator/message.rb, line 32
def not_enough_normal_after_rest_arguments(given, expected)
  n = expected - given
  not_enough_arg_names = @method.added.normal_params_after_rest.dup.pop(n).map{|x| x[1]}
  "Not enough arguments. Did you forget the following arguments? [#{not_enough_arg_names.join(', ')}]"
end
not_enough_norml_arguments(given, expected) click to toggle source

@param [Integer] given given args size. @param [Integer] expected expected args size. @return [Proc]

# File lib/rubocop/definition_validator/message.rb, line 23
def not_enough_norml_arguments(given, expected)
  n = expected - given
  not_enough_arg_names = @method.added.normal_params.dup.pop(n).map{|x| x[1]}
  "Not enough arguments. Did you forget the following arguments? [#{not_enough_arg_names.join(', ')}]"
end
suffix() click to toggle source
# File lib/rubocop/definition_validator/message.rb, line 62
def suffix
  "\nThis method is defined at #{@method.file_name} L#{@method.line}"
end
too_many_arguments() click to toggle source
# File lib/rubocop/definition_validator/message.rb, line 38
def too_many_arguments
  'Too many arguments'
end
unexpected_kwparam(unexpected) click to toggle source
# File lib/rubocop/definition_validator/message.rb, line 56
def unexpected_kwparam(unexpected)
  "The following keyword parameters are not expected. But received. [#{unexpected.join(', ')}]"
end