pocke / rbs_rails

Apache License 2.0
283 stars 33 forks source link

Should be set prefix for absolute namespace path #201

Closed ksss closed 3 years ago

ksss commented 3 years ago

gem delayed_job_active_record use ActiveRecord::Base for superclass. https://github.com/collectiveidea/delayed_job_active_record/blob/d65b0f9900f5b0c78c341c7c0209c2d138d64ec5/lib/delayed/backend/active_record.rb#L33

Then, rbs_rails:all task generate following rbs file.

module Delayed
  module Backend
    module ActiveRecord
      class Job < ActiveRecord::Base
      class ActiveRecord_Relation < ActiveRecord::Relation
      class ActiveRecord_Associations_CollectionProxy < ActiveRecord::Associations::CollectionProxy

Then, steep check displays the following error.

sig/rbs_rails/app/models/delayed/backend/active_record/job.rbs:4:6: [error] Cannot find type `ActiveRecord::Base`
│ Diagnostic ID: RBS::UnknownTypeName
│
└       class Job < ActiveRecord::Base
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

sig/rbs_rails/app/models/delayed/backend/active_record/job.rbs:445:8: [error] Cannot find type `ActiveRecord::Relation`
│ Diagnostic ID: RBS::UnknownTypeName
│
└         class ActiveRecord_Relation < ActiveRecord::Relation
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

sig/rbs_rails/app/models/delayed/backend/active_record/job.rbs:451:8: [error] Cannot find type `ActiveRecord::Associations::CollectionProxy`
│ Diagnostic ID: RBS::UnknownTypeName
│
└         class ActiveRecord_Associations_CollectionProxy < ActiveRecord::Associations::CollectionProxy
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Detected 3 problems from 1 file

This PR fixes this problem as follows.

module Delayed
  module Backend
    module ActiveRecord
      class Job < ::ActiveRecord::Base
      class ActiveRecord_Relation < ::ActiveRecord::Relation
      class ActiveRecord_Associations_CollectionProxy < ::ActiveRecord::Associations::CollectionProxy