Home

SVG RuboCop Logo, Copyright (c) 2014 Dimiter Petrov, CC BY-NC 4.0, see docs/images/logo/README.txt Yukihiro Matsumoto, Ruby Visual Identity Team, CC BY-SA 2.5, see docs/images/logo/README.txt SemVer.org Logo by @maxhaz, see docs/images/logo/README.txt

๐Ÿฆพ RuboCop LTS - Rules for Minimum Ruby Versions: Rubocop + Standard + Betterlint + Shopify + Gradual & More

๐Ÿ’ก See the intro blog post!


The RuboCop LTS family of gems is the distillation of almost 20 years of my own Ruby expertise and source code diving, built on the shoulders of the expertise of many others; organizing that expertise into per-Ruby-version sets of configurations.

Although the situation has improved somewhat, it remains unsafe to upgrade RuboCop, or Standard, in a project that supports EOL Rubies.

I hope it helps others avoid some of the challenges Iโ€™ve had with library maintenance, and supporting decade-old mission-critical applications.

Avoid bike-shedding, use rubocop-lts in every project, and let it manage your linting complexity!

If the rubocop-lts stack of libraries has helped you, or your organization, please support my efforts by making a donation, becoming a sponsor, or giving me a shout on Mastodon.

Liberapay Patrons Sponsor Me on Github

Buy me coffee donation button Patreon donate button


Table of Contents

Background & Theory

A Gem Family ๐Ÿ‘ช

The rubocop-lts family of gems has a version supporting any version of Ruby you need. They should be used as development dependencies for rubygems, libraries, or applications.

The project is distributed across multiple source hosts (i.e. actual DVCS), because source hosts have a history of not lasting long term, or becoming hostile to the ideals of open source.

Star the ones you use! Fork if you have an idea that would help the community of maintainers of old Ruby code.

Project GitLab GitHub
RuboCop LTS Org ย  GitHub Org's stars
rubocop-lts rubocop-lts GitLab stars rubocop-lts GitLab forks rubocop-lts GitHub stars rubocop-lts GitHub forks
standard-rubocop-lts standard-rubocop-lts GitLab stars standard-rubocop-lts GitLab forks standard-rubocop-lts GitHub stars standard-rubocop-lts GitHub forks
rubocop-ruby1_8 rubocop-ruby1_8 GitLab stars rubocop-ruby1_8 GitLab forks rubocop-ruby1_8 GitHub stars rubocop-ruby1_8 GitHub forks
rubocop-ruby1_9 rubocop-ruby1_9 GitLab stars rubocop-ruby1_9 GitLab forks rubocop-ruby1_9 GitLab stars rubocop-ruby1_9 GitLab forks
rubocop-ruby2_0 rubocop-ruby2_0 GitLab stars rubocop-ruby2_0 GitLab forks rubocop-ruby2_0 GitLab stars rubocop-ruby2_0 GitLab forks
rubocop-ruby2_1 rubocop-ruby2_1 GitLab stars rubocop-ruby2_1 GitLab forks rubocop-ruby2_1 GitLab stars rubocop-ruby2_1 GitLab forks
rubocop-ruby2_2 rubocop-ruby2_2 GitLab stars rubocop-ruby2_2 GitLab forks rubocop-ruby2_2 GitLab stars rubocop-ruby2_2 GitLab forks
rubocop-ruby2_3 rubocop-ruby2_3 GitLab stars rubocop-ruby2_3 GitLab forks rubocop-ruby2_3 GitLab stars rubocop-ruby2_3 GitLab forks
rubocop-ruby2_4 rubocop-ruby2_4 GitLab stars rubocop-ruby2_4 GitLab forks rubocop-ruby2_4 GitLab stars rubocop-ruby2_4 GitLab forks
rubocop-ruby2_5 rubocop-ruby2_5 GitLab stars rubocop-ruby2_5 GitLab forks rubocop-ruby2_5 GitLab stars rubocop-ruby2_5 GitLab forks
rubocop-ruby2_6 rubocop-ruby2_6 GitLab stars rubocop-ruby2_6 GitLab forks rubocop-ruby2_6 GitLab stars rubocop-ruby2_6 GitLab forks
rubocop-ruby2_7 rubocop-ruby2_7 GitLab stars rubocop-ruby2_7 GitLab forks rubocop-ruby2_7 GitLab stars rubocop-ruby2_7 GitLab forks
rubocop-ruby3_0 rubocop-ruby3_0 GitLab stars rubocop-ruby3_0 GitLab forks rubocop-ruby3_0 GitLab stars rubocop-ruby3_0 GitLab forks
rubocop-ruby3_1 rubocop-ruby3_1 GitLab stars rubocop-ruby3_1 GitLab forks rubocop-ruby3_1 GitLab stars rubocop-ruby3_1 GitLab forks
rubocop-ruby3_2 rubocop-ruby3_2 GitLab stars rubocop-ruby3_2 GitLab forks rubocop-ruby3_2 GitLab stars rubocop-ruby3_2 GitLab forks

Org Health ๐Ÿ‘ฉโ€๐Ÿ’ป

Gem Name Version Downloads CI Activity
rubocop-lts Gem Version Total DL DL Rank Main: Current
v0, ruby1.8+: 1.8 even
v2, ruby1.9+: 1.9 even
v4, ruby2.0+: 2.0 even
v6, ruby2.1+: 2.1 even
v8, ruby2.2+: 2.2 even
v10, ruby2.3+: 2.3 even
v12, ruby2.4+: 2.4 even
v14, ruby2.5+: 2.5 even
v16, ruby2.6+: 2.6 even
v18, ruby2.7+: 2.7 even
v20, ruby3.0+: 3.0 even
v22, ruby3.1+: 3.1 even
v24, ruby3.2+: 3.2 even
Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby1_8 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby1_9 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby2_0 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby2_1 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby2_2 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby2_3 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby2_4 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby2_5 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby2_6 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby2_7 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby3_0 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby3_1 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
rubocop-ruby3_2 Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs
standard-rubocop-lts Gem Version Total DL DL Rank Current Heads Open Issues Closed Issues Open PRs Closed PRs

Installation โœจ

Without bundler execute:

$ gem install rubocop-lts

Add this line to your applicationโ€™s Gemfile:

gem 'rubocop-lts', '~> X.0', require: false

NOTE: If you are on Rails, do not add require: false, or the Railtie which loads the rubocop_gradual rake task will not load.

NOTE: Figure out what X you need from the Version - Branch Matrix table.

Install for RubyGem

In your *.gemspec

# See table below for the right X based on the library's minimum Ruby version
spec.add_development_dependency 'rubocop-lts', '~> X.0'

# Add โฌ‡๏ธ **additional** โฌ‡๏ธ gem dependencies:
# IMPORTANT: rubocop-packaging's rules allow your gem to be packaged for linux distributions!
spec.add_development_dependency 'rubocop-packaging', '~> 0.5', '>= 0.5.2'

# Using RSpec? Add โ˜‘๏ธ **required** โ˜‘๏ธ gem dependencies (only required if using one of the RSpec configs)
spec.add_development_dependency 'rubocop-rspec', '~> 2.25'
spec.add_development_dependency 'rspec-block_is_expected', '~> 1.0', '>= 1.0.5'

Install for Rails Application

Rails-specific linting gems are not dependencies of this gem because Rails is just one way to build among many. If you are using Rails, please add them!

# Add โฌ‡๏ธ **additional** โฌ‡๏ธ gem dependencies for Rails-specific linting
group :development, :test do
  gem "standard-rails"
  gem "betterlint"
end

And then execute:

$ bundle

Usage ๐Ÿ”ง

In your .rubocop.yml do the following:

๐Ÿ”ฅ Delete the following line ๐Ÿ”ฅ

- inherit_from: .rubocop_todo.yml

You can probably ๐Ÿ”ฅ delete ๐Ÿ”ฅ most of the other lines too. This tool is anti-bike-shedding. You no longer need to worry about the rules!

๐Ÿ”ฅ Any of the following configs are no longer needed ๐Ÿ”ฅ

- require:
-   - 'betterlint'
-   - 'rubocop-md'
-   - 'rubocop-packaging'
-   - 'rubocop-performance'
-   - 'rubocop-rake'
-   - 'rubocop-rspec'
-   - 'rubocop-rails'
-   - 'rubocop-thread_safety'
-   - 'rubocop/gradual/patch'
-   - 'standard'
-   - 'standard-custom'
-   - 'standard-performance'
-   - 'standard-rails'
-   - 'standard-rubocop-lts'
- 
- AllCops:
-   NewCops: enable
-   DisplayCopNames: true
-   TargetRubyVersion: X.X

Then pick one of the following to add!

Ruby with RSpec

inherit_gem:
  rubocop-lts: rubocop-lts.yml # for the ruby + rspec
  # NOTE: this is the default, and as such, is equivalent to:
  # rubocop-lts: config/ruby_rspec.yml

Ruby (without RSpec)

inherit_gem:
  rubocop-lts: config/ruby.yml

Rails with RSpec

inherit_gem:
  rubocop-lts: config/rails_rspec.yml

Rails (without RSpec)

inherit_gem:
  rubocop-lts: config/rails.yml

RubyGem with RSpec

inherit_gem:
  rubocop-lts: config/rubygem_rspec.yml

RubyGem (without RSpec)

inherit_gem:
  rubocop-lts: config/rubygem.yml

Rake Tasks

NOTE: On Rails it is automatic, via Railtie, so you can skip this.

In a non-Rails environment add the following to your Rakefile:

require "rubocop/lts"
Rubocop::Lts.install_tasks

This will load the rubocop_gradual rake task, and alias it as rubocop.

Dependabot Noise Reduction

Pull Request noise reduction is possible!

Add the following to .github/dependabot.yml if you use Github Actions.

    ignore:
      - dependency-name: "rubocop-lts"

Git Branch Names

These wonโ€™t matter unless you want to contribute to the project, or you are adding the dependency via git.

Naming Scheme

"r{ ruby major }_{ ruby minor }-{ parity }-v{ gem-version }"

Parity

Even versions use the token even in the branch name. Please upgrade to an even release if not already on one! Odd versions use the token odd in the branch name, and are all deprecated. No further odd releases are planned.

Version - Branch Matrix

Ruby Version Major Version Num Parity Gem Version Branch Name
1.8 even 0.x r1_8-even-v0
1.9 even 2.x r1_9-even-v2
2.0 even 4.x r2_0-even-v4
2.1 even 6.x r2_1-even-v6
2.2 even 8.x r2_2-even-v8
2.3 even 10.x r2_3-even-v10
2.4 even 12.x r2_4-even-v12
2.5 even 14.x r2_5-even-v14
2.6 even 16.x r2_6-even-v16
2.7 even 18.x r2_7-even-v18
3.0 even 20.x r3_0-even-v20
3.1 even 22.x r3_1-even-v22
3.2 even 24.x r3_2-even-v24

Contributing โšก๏ธ

See CONTRIBUTING.md

Contributors ๐ŸŒˆ

Contributors

Made with contributors-img.

License ๐Ÿ“„

The gem is available as open source under the terms of the MIT License License: MIT. See LICENSE for the official Copyright Notice.

Project Logos (rubocop-lts) See [docs/images/logo/README.txt][project-logos]
Organization Logo (rubocop-lts) Author: [Yusuf Evli][org-logo-author] Source: [Unsplash][org-logo-source] License: [Unsplash License][org-logo-license]

Code of Conduct ๐Ÿค

Everyone interacting in the RuboCop LTS codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Versioning ๐Ÿ“Œ

This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions.

As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision.

For example:

spec.add_dependency "rubocop-lts", "~> X.0"

๐Ÿฟ Fun facts

Q: What does the team eat for breakfast each morning?

Wild chicken eggs. No, really. Here in Indonesia they are called โ€œtelur kampungโ€. Also, jasmine tea.

๐Ÿง™ Now do the thing

bundle add rubocop-lts

Posts

subscribe via RSS