Sord repeats parent class methods in each child class
connorshea opened this issue · 1 comments
connorshea commented
Describe the bug
This is probably more of a problem with YARD than Sord, but if you give it a file where Class A has methods, and then Class B is a child class of Class A, Class B will also have those methods. Sorbet can figure this out on its own, so it's not really necessary.
To Reproduce
Run optparser.rb
through Sord and see the various child classes of ParseError
.
Something like this:
class A
class ParseError < RuntimeError
def initialize(*args)
# code
end
def recover(argv)
# code
end
end
class NeedlessArgument < ParseError; end
class MissingArgument < ParseError; end
class InvalidOption < ParseError; end
end
Expected behavior
I'd expect it not to output a bunch of repetitive methods if they aren't redefined in the child classes:
class ParseError < RuntimeError
sig { params(args: T.untyped).void }
def initialize(*args); end
sig { params(argv: T.untyped).returns(T.untyped) }
def recover(argv); end
end
class NeedlessArgument < A::ParseError; end
class MissingArgument < A::ParseError; end
class InvalidOption < A::ParseError; end
Actual behavior
class ParseError < RuntimeError
sig { params(args: T.untyped).void }
def initialize(*args); end
sig { params(argv: T.untyped).returns(T.untyped) }
def recover(argv); end
end
class NeedlessArgument < A::ParseError
sig { params(args: T.untyped).void }
def initialize(*args); end
sig { params(argv: T.untyped).returns(T.untyped) }
def recover(argv); end
end
class MissingArgument < A::ParseError
sig { params(args: T.untyped).void }
def initialize(*args); end
sig { params(argv: T.untyped).returns(T.untyped) }
def recover(argv); end
end
class InvalidOption < A::ParseError
sig { params(args: T.untyped).void }
def initialize(*args); end
sig { params(argv: T.untyped).returns(T.untyped) }
def recover(argv); end
end
connorshea commented
Looks like we can pretty easily exclude inherited methods: https://www.rubydoc.info/gems/yard/YARD/CodeObjects/ClassObject#meths-instance_method