I've been very interested in adopting sorbet for strict types in ruby, but while installing it on my existing codebase i've run into a wall that I dont understand
I get the following error when running sbc tc
entities/user_entities.rb:25: The super class CrewManagement::Entities::UserBase of CrewManagement::Entities::UserEmbeds does not derive from Class https://srb.help/5067
25 | class UserEmbeds < UserBase
^^^^^^^^^^^^^^^^^^^^^^^^^^^
entities/user_entities.rb:6: CrewManagement::Entities::UserBase defined here
6 | class UserBase < CrewManagement::Entities::Mongoid
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
the sorbet docs say under error 5067
A class’s superclass (the Parent in class Child < Parent) must be statically resolvable to a class, not a module.
From what I understand, the error is saying that my class is not inheriting from a class, instead its suposedly inheriting from a module, but when I look at everything, i'm pretty sure everything is a class and that sorbet might be throwing a false positive.
entities/user_entities.rb
module CrewManagement
module Entities
## inherits from a different file
class UserBase < CrewManagement::Entities::Mongoid
expose :username
## ...
end
## inherits from declaration above
class UserEmbeds < UserBase
expose :_embedded do |record, opt|
embeds = {}
## ...
embeds
end
end
end
end
config/entities.rb
module CrewManagement
module Entities
## inherits from grape-entity gem
class Mongoid < Grape::Entity
format_with(:mongo_id, &:to_s)
with_options(format_with: :mongo_id) do
expose :_id, as: :id
end
expose :created_at
expose :updated_at
end
end
end
I think its flagging the grape-entity rubygem and not my codebase, but when i look at the rubygems source code i find that Grape::Entity is a class
https://github.com/ruby-grape/grape-entity/blob/master/lib/grape_entity/entity.rb
Is the error something that I can resolve with an RBI file declaration?
Runtime Details:
- OS - MacOS (Monterey) 12.5.1 (2.4 GHz 8-Core Intel Core i9)
- ruby - 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin21]
- rvm - 1.29.12
- gem sorbet-static-and-runtime - 0.5.10346
- gem tapioca - 0.10.0
- gem grape-entity - 0.10.2