A collection of Rubocop rules for Sorbet.
Just install the rubocop-sorbet gem
gem install rubocop-sorbet
or, if you use Bundler, add this line your application's Gemfile:
gem 'rubocop-sorbet', require: false
You need to tell RuboCop to load the Sorbet extension. There are three ways to do this:
Put this into your .rubocop.yml:
plugins: rubocop-sorbet
Alternatively, use the following array notation when specifying multiple extensions:
plugins:
- rubocop-sorbet
- rubocop-other-extension
Now you can run rubocop and it will automatically load the RuboCop Sorbet cops together with the standard cops.
[!NOTE] The plugin system is supported in RuboCop 1.72+. In earlier versions, use
requireinstead ofplugins.
rubocop --plugin rubocop-sorbet
RuboCop::RakeTask.new do |task|
task.plugins << 'rubocop-sorbet'
end
To enable the cops related to RBI files under the sorbet/rbi/ directory, put this in sorbet/rbi/.rubocop.yml:
inherit_gem:
rubocop-sorbet: config/rbi.yml
[!NOTE] If your top-level
.rubocop.ymldoes not loadrubocop-sorbet, you might need to also add arequire: rubocop-sorbetorplugins: rubocop-sorbetto thesorbet/rbi/.rubocop.ymlfile at the top.
This will turn off default cops for **/*.rbi files and enable the RBI specific cops.
You'll also need to add an entry to the main .rubocop.yml so that RBI files are included, e.g.:
AllCops:
Include:
- "sorbet/rbi/shims/**/*.rbi"
All cops are located under lib/rubocop/cop/sorbet, and contain examples/documentation.
In your .rubocop.yml, you may treat the Sorbet cops just like any other cop. For example:
Sorbet/FalseSigil:
Exclude:
- lib/example.rb
You can read about each cop supplied by RuboCop Sorbet in the manual.
Sorbet cops support the following versions:
See CONTRIBUTING.md for details on how to contribute to this project.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Rubocop::Sorbet project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
5,477 followers · starred May 2024
480 followers · starred Feb 2020
251 followers · starred Nov 2022
122 followers · starred Nov 2019
A collection of Rubocop rules for Sorbet.
Just install the rubocop-sorbet gem
gem install rubocop-sorbet
or, if you use Bundler, add this line your application's Gemfile:
gem 'rubocop-sorbet', require: false
You need to tell RuboCop to load the Sorbet extension. There are three ways to do this:
Put this into your .rubocop.yml:
plugins: rubocop-sorbet
Alternatively, use the following array notation when specifying multiple extensions:
plugins:
- rubocop-sorbet
- rubocop-other-extension
Now you can run rubocop and it will automatically load the RuboCop Sorbet cops together with the standard cops.
[!NOTE] The plugin system is supported in RuboCop 1.72+. In earlier versions, use
requireinstead ofplugins.
rubocop --plugin rubocop-sorbet
RuboCop::RakeTask.new do |task|
task.plugins << 'rubocop-sorbet'
end
To enable the cops related to RBI files under the sorbet/rbi/ directory, put this in sorbet/rbi/.rubocop.yml:
inherit_gem:
rubocop-sorbet: config/rbi.yml
[!NOTE] If your top-level
.rubocop.ymldoes not loadrubocop-sorbet, you might need to also add arequire: rubocop-sorbetorplugins: rubocop-sorbetto thesorbet/rbi/.rubocop.ymlfile at the top.
This will turn off default cops for **/*.rbi files and enable the RBI specific cops.
You'll also need to add an entry to the main .rubocop.yml so that RBI files are included, e.g.:
AllCops:
Include:
- "sorbet/rbi/shims/**/*.rbi"
All cops are located under lib/rubocop/cop/sorbet, and contain examples/documentation.
In your .rubocop.yml, you may treat the Sorbet cops just like any other cop. For example:
Sorbet/FalseSigil:
Exclude:
- lib/example.rb
You can read about each cop supplied by RuboCop Sorbet in the manual.
Sorbet cops support the following versions:
See CONTRIBUTING.md for details on how to contribute to this project.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Rubocop::Sorbet project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
5,477 followers · starred May 2024
480 followers · starred Feb 2020
251 followers · starred Nov 2022
122 followers · starred Nov 2019