-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New rule: Unnecessary Method #97
Comments
To be more general, we can report any method which implements only call to |
Probably as long as the params/types are the same. For example: abstract class Parent
def bark(name : String)
pp name
end
end
class Child < Parent
def bark(name : String)
super
end
end Would also be unnecessary. abstract class Parent
def bark(name : String)
pp name
end
end
class Child < Parent
def bark(name : String, some_bool)
super name
end
end Would be required since the params are not the same. |
I found this tricky way to expose parent's private method in std lib: class A
private def method(a)
puts a
end
end
class B < A
def method(b)
super
end
end
B.new.method(10) #=> 10 maybe this is not the best architecture but it looks like the language intentionally allows it. So we don't want to disallow this by Ameba. FYI Ameba is a syntax analyzer, meaning it can't get info about parent class (it can be located in a different file). So there is no way to distinguish between a real "unnecessary method" and the intentional call to |
Given the following code:
The child's initializer isn't required since it is the same as the parent.
The text was updated successfully, but these errors were encountered: