https://github.com/rubocop/rubocop-performance
An extension of RuboCop focused on code performance checks.
https://github.com/rubocop/rubocop-performance
code-formatter hacktoberfest linter rubocop ruby static-code-analysis
Last synced: 4 days ago
JSON representation
An extension of RuboCop focused on code performance checks.
- Host: GitHub
- URL: https://github.com/rubocop/rubocop-performance
- Owner: rubocop
- License: mit
- Created: 2018-06-10T12:08:51.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-04-03T17:42:37.000Z (11 days ago)
- Last Synced: 2025-04-09T21:41:23.690Z (5 days ago)
- Topics: code-formatter, hacktoberfest, linter, rubocop, ruby, static-code-analysis
- Language: Ruby
- Homepage: https://docs.rubocop.org/rubocop-performance
- Size: 24.7 MB
- Stars: 709
- Watchers: 12
- Forks: 83
- Open Issues: 53
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-ruby - Rubocop Performance - A RuboCop extension focused on code performance checks. (Code Formatting)
- awesome-rails-gems - rubocop / rubocop-performance
- stars - rubocop/rubocop-performance - An extension of RuboCop focused on code performance checks. (Ruby)
- learn-ruby -
README
# RuboCop Performance
[](https://badge.fury.io/rb/rubocop-performance)
[](https://github.com/rubocop/rubocop-performance/actions/workflows/test.yml)
[](https://discord.gg/wJjWvGRDmm)Performance optimization analysis for your projects, as an extension to [RuboCop](https://github.com/rubocop/rubocop).
## Installation
Just install the `rubocop-performance` gem
```sh
$ gem install rubocop-performance
```or if you use bundler put this in your `Gemfile`
```ruby
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`.
```yaml
plugins: rubocop-performance
```Alternatively, use the following array notation when specifying multiple extensions.
```yaml
plugins:
- rubocop-other-extension
- rubocop-performance
```Now you can run `rubocop` and it will automatically load the RuboCop Performance
cops together with the standard cops.> [!NOTE]
> The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.### Command line
```sh
$ rubocop --plugin rubocop-performance
```### Rake task
```ruby
require 'rubocop/rake_task'RuboCop::RakeTask.new do |task|
task.plugins << 'rubocop-performance'
end
```## The Cops
All cops are located under
[`lib/rubocop/cop/performance`](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:```yaml
Performance/Size:
Exclude:
- lib/example.rb
```## Documentation
You can read a lot more about RuboCop Performance in its [official docs](https://docs.rubocop.org/rubocop-performance/).
## Compatibility
RuboCop Performance complies with the RuboCop core compatibility.
See the [compatibility documentation](https://docs.rubocop.org/rubocop/compatibility.html) 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](CONTRIBUTING.md).
## License
`rubocop-performance` is MIT licensed. [See the accompanying file](LICENSE.txt) for
the full text.