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

Should we expose our style guide as a gem? #140

Closed
sambostock opened this issue Feb 13, 2020 · 3 comments · Fixed by #142
Closed

Should we expose our style guide as a gem? #140

sambostock opened this issue Feb 13, 2020 · 3 comments · Fixed by #142

Comments

@sambostock
Copy link
Contributor

TL;DR

It might make sense for us to expose the styleguide as a gem, allowing configuration updates to become part of the predicatable Dependabot auto-update process.


Details

As brought up in Slack

Currently, the way we share our Rubocop config across repos is

# .rubocop.yml
inherit_from:
  - http://shopify.github.io/ruby-style-guide/rubocop.yml

The thing is, this doesn't follow any kind of versioning. It just follows the rules from inheriting from a remote URL

The remote config file is cached locally and is only updated if:

  • The file does not exist.
  • The file has not been updated in the last 24 hours.
  • The remote copy has a newer modification time than the local copy.

Sometimes the file is gitignored, sometimes it isn't.

  • If it is ignored, then sometimes new rules start being enforced in CI.
  • If it isn't, then sometimes a random PR will have updates to the style config.

Given that we have Dependabot to keep dependencies up to date, and it is possible to include Rubocop config in a gem, would it make sense to publish our config as a gem, and use inherit_gem to apply it?

Other benefits that come to mind are:

  • We could explicitly make Rubocop a dependency.
    No more incompatible cops due to version mismatches!
  • We could use existing dependency tooling to check for up-to-date style configs (e.g. Services Internal classification checks)
  • We could add dependencies on the extracted cop gems (e.g. rubocop-performance), without requiring the client to know to install those cops

If we wanted to get really bold, maybe a gem would even be a good place to put the common foundation for a command similar to dev style --include-branch-commits, instead of every repo implementing it on their own.


cc. @rafaelfranca

@volmer
Copy link
Contributor

volmer commented Feb 13, 2020

I like the idea. The gem would need to be public, though, since this style guide (and the RuboCop config yml) is public on GH pages and open source repos rely on it. I think also we should make this very repo public, unless there's some good reason not to do it?

@larouxn
Copy link
Contributor

larouxn commented Feb 21, 2020

I also think it would be a great idea to release our style guide as a gem. Would be easier to update, we'd gain versioning which would be neat, and we could (probably) match releases to Rubocop versions, if we want. The latter would also make updating code that's been stuck on an older version of the style guide and/or Rubocop easier.

@rafaelfranca
Copy link
Member

I'm not comfortable with opening this repo due to the discussion that happen here but I think the gem should be public. I'm working on it.

rafaelfranca added a commit that referenced this issue Feb 25, 2020
This will make easier to use in the projects since change to this
repository will not automatically be applied to users and we don't need
to deal with caches anymore.

We can also define which minimal version of rubocop we support now.

As we upgrade our gems using dependabot by default, every time we
release a new version of the style guide, the projects will receive the
new version as a PR.

Closes #140.
rafaelfranca added a commit that referenced this issue Feb 26, 2020
This will make easier to use in the projects since change to this
repository will not automatically be applied to users and we don't need
to deal with caches anymore.

We can also define which minimal version of rubocop we support now.

As we upgrade our gems using dependabot by default, every time we
release a new version of the style guide, the projects will receive the
new version as a PR.

Closes #140.
rafaelfranca added a commit that referenced this issue Feb 26, 2020
This will make easier to use in the projects since change to this
repository will not automatically be applied to users and we don't need
to deal with caches anymore.

We can also define which minimal version of rubocop we support now.

As we upgrade our gems using dependabot by default, every time we
release a new version of the style guide, the projects will receive the
new version as a PR.

Closes #140.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants