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

Note: in order to use the Sorbet/SignatureBuildOrder cop autocorrect feature, it is necessary to install unparser in addition to rubocop-sorbet.

gem "unparser", require: false


You need to tell RuboCop to load the Sorbet extension. There are three ways to do this:

RuboCop configuration file

Put this into your .rubocop.yml:

require: rubocop-sorbet

Alternatively, use the following array notation when specifying multiple extensions:

  - rubocop-other-extension
  - rubocop-sorbet

Now you can run rubocop and it will automatically load the RuboCop Sorbet cops together with the standard cops.

Command line

rubocop --require rubocop-sorbet

Rake task do |task|
  task.requires << 'rubocop-sorbet'

Rubocop rules for RBI files

To enable the cops related to RBI files under the sorbet/rbi/ directory, put this in sorbet/rbi/.rubocop.yml:

  rubocop-sorbet: config/rbi.yml

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.:

    - "sorbet/rbi/shims/**/*.rbi"

The Cops

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:

    - lib/example.rb


You can read about each cop supplied by RuboCop Sorbet in the manual.


Sorbet cops support the following versions:

  • Sorbet >= 0.5
  • Ruby >= 2.5


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

To contribute a new cop, please use the supplied generator like this:

bundle exec rake "new_cop[Sorbet/NewCopName]"

which will create a skeleton cop, a skeleton spec, an entry in the default config file and will require the new cop so that it is properly exported from the gem.

Don't forget to update the documentation with:

bundle exec rake generate_cops_documentation


The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Rubocop::Sorbet project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.