-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Best way to apply to all rbi
files in the project
#94
Comments
👋 Hey Robin, We provide two config within this suite of cops:
Which one is causing you trouble? From the inclusion of |
I tried both...
If I understand correctly, the only way I can get Is there any path forward besides adding |
rbi
files in the project
I think your top level Rubocop configuration should only use If you want to apply the |
That makes sense, though I think the But doesn't this leave us with |
The But yeah I agree we can make the README clearer. I'll push a change 👍 |
So I might just be experiencing an issue caused by my Rubocop config, but it doesn't seem to be working as I expect from your description. I have a file My understanding of this is: I have require:
- rubocop-sorbet
inherit_gem:
rubocop-sorbet: config/rbi.yml My top-level project require:
- standard
- rubocop-rails
- rubocop-sorbet
inherit_gem:
standard: config/base.yml
rubocop-rails: config/default.yml
rubocop-sorbet: config/default.yml
AllCops:
TargetRubyVersion: 3.0
Exclude:
- "Gemfile.lock"
- "bin/*"
- "config.ru" When I run
So it seems to inherit the entire top-level config in the subdirectory no matter what. I can't get it to run correctly from either the top level (it's ignoring all Looking at the Tapioca project, the top-level rubocop config doesn't seem to use rubocop-sorbet's default.yml config, and that top-level config adds an And I wonder if the tapioca project is applying all of the standard rules to the contents of the |
I've been testing this with this setup:
Where require:
- rubocop-sorbet
inherit_gem:
rubocop-sorbet: config/default.yml
AllCops:
Include:
- "**/*.rbi" And require:
- rubocop-sorbet
inherit_gem:
rubocop-sorbet: config/rbi.yml And finally running rubocop:
Would that work with your project? |
Adding the following to AllCops:
Include:
- "**/*.rbi" causes all configured cops to evaluate I see two solutions:
|
👋 Hey Robin, I might be missing something from your configuration because I'm unable to reproduce what you're saying. Let's take this demo repo as example:
As you can see when you run
As you can see, no Note that a Do you mind trying with this demo repo and validate that we're seeing the same behavior? I hope it helps 🙏 |
Thank you @Morriar! I was able to verify that the demo repo works as expected. I want to deeper analyze the differences with my project, but I'll go ahead and close this for now. I really appreciate your time on this! |
I was able to give this another look with the benefit of more experience with Sorbet. The base issue that confused me is that though I'm using I understand now that Shopify is using Tapioca to generate/maintain RBI files, so that is not wholly unexpected. I hope to get Tapioca working in my Rails project in the future. Rather than apply tens of thousands of autofixes and continue to maintain those (which I couldn't actually do because it crashed rubocop), I chose to add |
👋 Hey Robin, I should have added that most of this rules are too enforce styling on manually written RBI files (called shims). We generally exclude auto-generated files from Rubocop. Thanks for the feedback! |
This is not strictly an issue with rubocop-sorbet, but I've been unable to find a general solution to this problem, and it keeps us from being able to use rubocop-sorbet.
The issue being that once
**/*.rbi
is added to theInclude
list for rubocop, it causes all of the other configured cops to run on rbi files, making a lot of complaints (and changes). And of course rbi generation going forward will continue to create them as-is, so in my mind it's not desirable to enforce the same rubocop rules within rbi files.My preference would be to only include rbi files for the Sorbet cops, and exclude them for all other cops, but there's no elegant way to do this.
Can anyone provide some guidance on this? I can open a PR to add to the README if we can come up with a solution.
The text was updated successfully, but these errors were encountered: