Method
Object#some_method
is defined at both ruby/code.rb:33 and ruby/code.rb:59.56# Raises "put empty method definitions on a single line"
57# Also raises "multiple methods with same name in the same scope" as we have a
58# method with same name above
59def some_method60end
61
62# Raises "Invalid annotation keyword format detected"
Method
Object#some_method
is defined at both ruby/code.rb:33 and ruby/code.rb:38.35end
36
37# Raises "unreachable code detected"
38def some_method39 return
40 do_something
41end
Description
Each method in a scope should have a unique name. Having multiple methods with the same name is usually a result of typos.
Bad practice
def f
puts "Hello"
end
def f
puts "World"
end
def g
puts "!"
end
alias f g
Recommended
def f
puts "Hello"
end
def g
puts "World"
end
def h
puts "!"
end
alias i h