Skip to content
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

A cop that enforces Gemfile vs gems.rb #9580

Closed
ngan opened this issue Mar 10, 2021 · 6 comments
Closed

A cop that enforces Gemfile vs gems.rb #9580

ngan opened this issue Mar 10, 2021 · 6 comments
Labels
feature request good first issue Easy task, suitable for newcomers to the project

Comments

@ngan
Copy link

ngan commented Mar 10, 2021

Is your feature request related to a problem? Please describe.

I'm kicking the tires on changing our Gemfile to gems.rb. However, we have many internal gems within our monorepo and it just occurred to me that it would be cool to have a configurable cop that enforces one or the other.

Describe the solution you'd like

A cop that checks to make sure you have a Gemfile or a gems.rb (and it counterpart lockfiles) depending on what you've configured. Maybe we default to the newer gems.rb?

@koic
Copy link
Member

koic commented Mar 10, 2021

As far as I've heard from Bundler committer at a conference of Ruby a few years ago, the default is Gemfile, and gems.rb is never the default. (gems.rb was likely to be the default at one point when Bundler 2.0.0-dev was being developed, but it was rejected.)
It may be useful to unify to Gemfile, but I'm not sure whether it's worth providing an alternative to unify to gems.rb.

@bbatsov
Copy link
Collaborator

bbatsov commented Mar 10, 2021

I recall something similar, but in general I don't mind the proposal for this cop. It's going to be very easy to implement. Frankly, I've always hated the convention of Ruby files without extensions, as this made it opaque whether those are Ruby files or not, but I guess the original plans changed because there were many concerns about breakages in case of a forceful push to gems.rb.

@ngan
Copy link
Author

ngan commented Mar 10, 2021

🤔 This is actually surprising to me. @deivid-rodriguez do you have any insights?

@deivid-rodriguez
Copy link
Contributor

Yes, it's exactly as @bbatsov guessed. There used to be plans to make the switch and make gems.rb the default, because of the weird extensionless term "Gemfile" (it's redundant, since it's obviously a file, but not transparent about being a ruby file). But we ended up cancelling them because we deemed the disruption as too big, and we had much more important issues to deal with. We have no plans on dropping support for gems.rb either, so this cop seems fine to me too.

@bbatsov bbatsov added feature request good first issue Easy task, suitable for newcomers to the project labels Mar 22, 2021
@rubyFeedback
Copy link

bbatsov wrote:

as this made it opaque whether those are Ruby files or not, but I guess the original plans changed
because there were many concerns about breakages in case of a forceful push to gems.rb

Same here. I even changed files such as "README" to "README.md" because it helps my brain
make a mental association, aka "this file is a markdown file". (Yes, not every README file is
necessarily a README.md, I understand that, but I just love the markdown format; it's sooo
convenient. I sort of get extra-display value, for just marginal changes. Contrast this to XML,
but also yaml, which, while a nice format, is very picky and can be error prone, in particular
in larger yaml files.)
deivid-rodriguez wrote:

But we ended up cancelling them because we deemed the disruption as too big

Personally I just use .gemspec files anyway and even have custom ruby code to
autogenerate these when I need them. My long term dream, though, is to have
rubocop be a meta-cop that actually can help re-write TONS of things. Not just
ruby, but also autogenerate crystal code, or at the least what can be inferred.
But I am going too off-topic now, sorry. :D

@keshavbiswa
Copy link

Is this still available? Looks like a good first issue for me to get my hands on 😄

gregfletch added a commit to gregfletch/rubocop that referenced this issue Aug 22, 2021
Add a new cop which enforces which bundler gem filename to use. By default, enforces Gemfile and its related Gemfile.lock file. Alternatively, setting RequiresGemfile to false enforces gems.rb and its related gems.locked file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request good first issue Easy task, suitable for newcomers to the project
Projects
None yet
Development

No branches or pull requests

6 participants