Skip to content

Tapioca does not generate RBI methods for Struct subclasses #1384

Open
@bdewater

Description

@bdewater

Pulling this out of the Sorbet Slack space and putting it here in case people are surprised by this and can find something about it.

I noticed this pattern in Faraday (ref lostisland/faraday#1489 and lostisland/faraday#1491):

class SSLOptions < Struct.new(:verify_hostname)
  def verify?; end
end

tapioca gem generates RBI methods for verify? but not for verify_hostname/verify_hostname=. The Ruby docs recommend the block form to define a struct, which avoids creating an unused anonymous class in the ancestor chain:

SSLOptions = Struct.new(:verify_hostname) do
  def verify?; end
end

which also happens to help Tapioca pick the verify_hostname/verify_hostname= methods.

It seems in #464 the intent was to fix this, but it seems to have been abandoned. IDK if this is still the plan or that people should just use the Style/StructInheritance Rubocop to avoid the issue from occurring?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions