A long-lived project that still receives updates
A collection of RuboCop cops to check for performance optimizations in Ruby code.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.48.1, < 2.0
>= 1.31.1, < 2.0
 Project Readme

RuboCop Performance

Gem Version CI Discord

Performance optimization analysis for your projects, as an extension to RuboCop.

Installation

Just install the rubocop-performance gem

$ gem install rubocop-performance

or if you use bundler put this in your Gemfile

gem 'rubocop-performance', require: false

Usage

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

RuboCop configuration file

Put this into your .rubocop.yml.

require: rubocop-performance

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

require:
  - rubocop-other-extension
  - rubocop-performance

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

Command line

$ rubocop --require rubocop-performance

Rake task

require 'rubocop/rake_task'

RuboCop::RakeTask.new do |task|
  task.requires << 'rubocop-performance'
end

The Cops

All cops are located under lib/rubocop/cop/performance, and contain examples/documentation.

In your .rubocop.yml, you may treat the Performance cops just like any other cop. For example:

Performance/Size:
  Exclude:
    - lib/example.rb

Documentation

You can read a lot more about RuboCop Performance in its official docs.

Compatibility

RuboCop Performance complies with the RuboCop core compatibility.

See the compatibility documentation for further details.

Note: Performance cops are all MRI focused and are highly dependent of the version of MRI you're using.

Contributing

Checkout the contribution guidelines.

License

rubocop-performance is MIT licensed. See the accompanying file for the full text.