MethodNameChecker::RB_RESERVED_WORDS is the list of reserved words in Ruby that take an argument. Unlike VariableNameChecker::RB_RESERVED_WORDS, these reserved words require an argument, and a NoMethodError is raised due to the presence of the argument.
The MethodNameChecker will use this list to suggest a reversed word if a NoMethodError is raised and found closest matches.
Also see VariableNameChecker::RB_RESERVED_WORDS.
# File ruby-3.1.2/lib/did_you_mean/spell_checkers/method_name_checker.rb, line 48
def corrections
@corrections ||= begin
dictionary = method_names
dictionary = RB_RESERVED_WORDS + dictionary if @private_call
SpellChecker.new(dictionary: dictionary).correct(method_name) - names_to_exclude
end
end
# File ruby-3.1.2/lib/did_you_mean/spell_checkers/method_name_checker.rb, line 57
def method_names
if Object === receiver
method_names = receiver.methods + receiver.singleton_methods
method_names += receiver.private_methods if @private_call
method_names.uniq!
method_names
else
[]
end
end