Home
๐ฆพ 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.
Table of Contents
- ๐ฉโ๐ป Org Health
- ๐ช A Gem Family
- โจ Installation
- ๐ง Usage
- โก๏ธ Contributing
- ๐ Contributors
- ๐ License
- ยฉ Copyright
- ๐ค Code of Conduct
- ๐ Versioning
Background & Theory
- ๐ฑ Why Build This
- ๐ฑ Convention > Configuration
- ๐ฑ Even Releases
- ๐ฑ How to Upgrade Ruby (1.8 to 3.2)!
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.
Org Health ๐ฉโ๐ป
Gem Name | Version | Downloads | CI | Activity |
---|---|---|---|---|
rubocop-lts |
Main: v0, ruby1.8+: v2, ruby1.9+: v4, ruby2.0+: v6, ruby2.1+: v8, ruby2.2+: v10, ruby2.3+: v12, ruby2.4+: v14, ruby2.5+: v16, ruby2.6+: v18, ruby2.7+: v20, ruby3.0+: v22, ruby3.1+: v24, ruby3.2+: |
|||
rubocop-ruby1_8 |
||||
rubocop-ruby1_9 |
||||
rubocop-ruby2_0 |
||||
rubocop-ruby2_1 |
||||
rubocop-ruby2_2 |
||||
rubocop-ruby2_3 |
||||
rubocop-ruby2_4 |
||||
rubocop-ruby2_5 |
||||
rubocop-ruby2_6 |
||||
rubocop-ruby2_7 |
||||
rubocop-ruby3_0 |
||||
rubocop-ruby3_1 |
||||
rubocop-ruby3_2 |
||||
standard-rubocop-lts |
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 ๐
Made with contributors-img.
License ๐
The gem is available as open source under the terms of the MIT License . 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]Copyright ยฉ
- Copyright (c) 2022 - 2023 Peter H. Boling of Rails Bling
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