DEV Community

Cover image for Rubocop LTS
Peter H. Boling
Peter H. Boling

Posted on

Rubocop LTS

Cover Photo by eberhard 🖐 grossgasteiger


My last post addressed the popular rubygem rubocop, its lack of SemVer (Semantic Versioning) adherence, and introduced a new set of gems aimed at mitigating build failures due to ill-advised rubocop upgrades.

But switching to this new paradigm would require each project to manage the version of rubocop-ruby*_* that matches the oldest Ruby they intend to support, and this would also mean polluting .rubocop.yml with a Ruby version specific string, like

inherit_gem:
  rubocop-ruby2_4: rubocop.yml
Enter fullscreen mode Exit fullscreen mode

We need to level up the solution one more time.

What if we could leverage rubygems and bundler abilities to resolve dependencies, and just keep it at one sigle gem, which would only update when there is little to no risk.

We could name this gem rubocop-lts.

It would follow SemVer, and each major version step would signify one version of Ruby being dropped. It would have a static RuboCop config which would load the underlying config from rubocop-ruby*_* that matches the ruby, resulting in zero code changes outside bumping the major version in the gemfile when you go to upgrade Ruby. It will handle knowing which version of RuboCop is right.

The inherit_gem lines won't change no matter what version of Ruby, or RuboCop, you are pegged to.

inherit_gem:
  rubocop-lts: rubocop-lts.yml
Enter fullscreen mode Exit fullscreen mode

What if this new gem materialized before your very eyes?

I'm working on it over here! Please join me! The intial releases are all complete, and ready to use.

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay