Method
Object#some_method
is defined at both ruby/code.rb:31 and ruby/code.rb:57.54# Raises "put empty method definitions on a single line"
55# Also raises "multiple methods with same name in the same scope" as we have a
56# method with same name above
57def some_method58end
59
60# Raises "Invalid annotation keyword format detected"
Method
Object#some_method
is defined at both ruby/code.rb:31 and ruby/code.rb:36.33end
34
35# Raises "unreachable code detected"
36def some_method37 return
38 do_something
39end
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