ruby / rbs

Type Signature for Ruby
Other
1.91k stars 201 forks source link

Feature proposal: Multiple error on `rbs validate` #1543

Closed ksss closed 7 months ago

ksss commented 9 months ago

The rbs validate command only outputs a single error at a time. However, when there are multiple issues, we have to go through a cycle of resolving errors, running rbs validate, resolving errors again, and running rbs validate repeatedly.

This issue is especially prevalent when auto-generating RBS, and it slows down the improvement cycle for addressing problems.

I propose resolving this issue by enhancing the rbs validate command to provide as much error information as possible when executed.

Expected behavior.

$ cat t.rbs
class Foo
  def foo: () -> voids # typo
  def bar: -> Bar      # no type found
  def bar: -> Bar      # duplicated method
end

$ bundle exec rbs -I t.rbs validate --silent
t.rbs:2:17...2:22: Could not find voids (RBS::NoTypeFoundError)

    def foo: () -> voids
                   ^^^^^

t.rbs:3:14...3:17: Could not find Bar (RBS::NoTypeFoundError)

    def bar: -> Bar
                ^^^

t.rbs:3:2...3:17: ::Foo#bar has duplicated definitions in t.rbs:4:2...4:17 (RBS::DuplicatedMethodDefinitionError)

    def bar: -> Bar
    ^^^^^^^^^^^^^^^
soutaro commented 8 months ago

Sounds good. 👍