Shopify / tapioca

The swiss army knife of RBI generation
MIT License
720 stars 120 forks source link

RuboCop RBI appears to be pulling in rubocop-rspec when typechecking #1982

Open p-linnane opened 1 month ago

p-linnane commented 1 month ago

Hello šŸ‘‹ . I'm a maintainer for the Homebrew project. This is my first issue in the Tapioca repo, so please bear with me if I haven't filled this out properly.

While updating to RuboCop v1.65.1, we are encountering typechecking failures. The RuboCop RBI appears to be trying to pull in rubocop-rspec.

Run brew typecheck
sorbet/rbi/gems/rubocop@1.65.1.rbi:29637: Unable to resolve constant `Base` https://srb.help/5002
       29637 |class RuboCop::Cop::RSpec::MultipleExpectations < ::RuboCop::Cop::RSpec::Base
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  Did you mean `RuboCop::Cop::Base`? Use `-a` to autocorrect
    sorbet/rbi/gems/rubocop@1.65.1.rbi:29637: Replace with `RuboCop::Cop::Base`
       29637 |class RuboCop::Cop::RSpec::MultipleExpectations < ::RuboCop::Cop::RSpec::Base
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rbi/gems/rubocop@1.65.1.rbi:2929: `RuboCop::Cop::Base` defined here
    2929 |class RuboCop::Cop::Base
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/rubocop@1.65.1.rbi:29671: Unable to resolve constant `Base` https://srb.help/5002
       29671 |class RuboCop::Cop::RSpec::MultipleMemoizedHelpers < ::RuboCop::Cop::RSpec::Base
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  Did you mean `RuboCop::Cop::Base`? Use `-a` to autocorrect
    sorbet/rbi/gems/rubocop@1.65.1.rbi:29671: Replace with `RuboCop::Cop::Base`
       29671 |class RuboCop::Cop::RSpec::MultipleMemoizedHelpers < ::RuboCop::Cop::RSpec::Base
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rbi/gems/rubocop@1.65.1.rbi:2929: `RuboCop::Cop::Base` defined here
    2929 |class RuboCop::Cop::Base
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/rubocop@1.65.1.rbi:29702: Unable to resolve constant `Base` https://srb.help/5002
       29702 |class RuboCop::Cop::RSpec::NestedGroups < ::RuboCop::Cop::RSpec::Base
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  Did you mean `RuboCop::Cop::Base`? Use `-a` to autocorrect
    sorbet/rbi/gems/rubocop@1.65.1.rbi:29702: Replace with `RuboCop::Cop::Base`
       29702 |class RuboCop::Cop::RSpec::NestedGroups < ::RuboCop::Cop::RSpec::Base
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rbi/gems/rubocop@1.65.1.rbi:2929: `RuboCop::Cop::Base` defined here
    2929 |class RuboCop::Cop::Base
          ^^^^^^^^^^^^^^^^^^^^^^^^
Errors: 3
Check https://docs.brew.sh/Typechecking for more information on how to resolve these errors.

You can view our CI run here for exactly what's happening: https://github.com/Homebrew/brew/actions/runs/10239923250/job/28326083691?pr=17928

egiurleo commented 4 weeks ago

Hi, @p-linnane, we're currently working on solving this as part of #293. The issue is that Tapioca is attributing these methods to the rubocop gem rather than rubocop-rspec, which is why it's writing the methods in this RBI file.

Let me know if these errors are blocking you and you need help finding a workaround!

p-linnane commented 3 weeks ago

Hi @egiurleo. We are not currently able to upgrade RuboCop for Homebrew while this issue persists. I'll keep an eye on the PR you linked.

egiurleo commented 3 weeks ago

I'll follow up once the new behavior is ready to be tested to make sure it solves your use case.

In the meantime, you might consider overriding the strictness level of rubocop gem RBI so that it won't cause type errors. It's not a good long-term solution because obviously you lose some type safety, but it's helpful for temporary unblocking.