A summary of data about the Ruby ecosystem.

https://github.com/rubocop/rubocop-rails

A RuboCop extension focused on enforcing Rails best practices and coding conventions.
https://github.com/rubocop/rubocop-rails

Keywords

code-formatter hacktoberfest linter rails rubocop ruby static-code-analysis

Keywords from Contributors

activerecord activejob mvc rubygems rspec static-analysis rack capybara ruby-gem crash-reporting

Last synced: about 6 hours ago
JSON representation

Repository metadata

A RuboCop extension focused on enforcing Rails best practices and coding conventions.

README.md

RuboCop Rails

Gem Version
CI

A RuboCop extension focused on enforcing Rails best practices and coding conventions.

[!IMPORTANT]
This repository manages rubocop-rails gem (>= 2.0.0). rubocop-rails gem (<= 1.5.0) has been renamed to rubocop-rails_config gem.

Installation

Just install the rubocop-rails gem

$ gem install rubocop-rails

or if you use bundler put this in your Gemfile

gem 'rubocop-rails', require: false

Usage

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

RuboCop configuration file

Put this into your .rubocop.yml.

plugins: rubocop-rails

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

plugins:
  - rubocop-other-extension
  - rubocop-rails

Now you can run rubocop and it will automatically load the RuboCop Rails
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

$ rubocop --plugin rubocop-rails

Rake task

require 'rubocop/rake_task'

RuboCop::RakeTask.new do |task|
  task.plugins << 'rubocop-rails'
end

RuboCop Rails configuration

The following settings specific to RuboCop Rails can be configured in .rubocop.yml.

AllCops: TargetRailsVersion

What version of Rails is the inspected code using? If a value is specified
for TargetRailsVersion then it is used. Acceptable values are specified
as a float (e.g., 7.2); the patch version of Rails should not be included.

AllCops:
  TargetRailsVersion: 7.2

If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or
gems.locked file to find the version of Rails that has been bound to the
application. If neither of those files exist, RuboCop will use Rails 5.0
as the default.

AllCops: MigratedSchemaVersion

By specifying the MigratedSchemaVersion option, migration files that have already been run can be ignored.
When MigratedSchemaVersion: '20241225000000' is set, migration files lower than or equal to '20241225000000' will be ignored.
For example, to ignore db/migrate/20241225000000_create_articles.rb and earlier migrations you would configure it the following way:

AllCops:
  MigratedSchemaVersion: '20241225000000'

This prevents inspecting schema settings for already applied migration files.
Changing already applied migrations should be avoided because it can lead to the schema getting out of sync
between your local copy and what it actually is in production, depending on when bin/rails db:migrate was executed.
If you want to modify your schema to comply with the cops, you should instead create new migrations.

Rails configuration tip

In Rails 6.1+, add the following config.generators.after_generate setting to
your config/environments/development.rb to apply RuboCop autocorrection to code generated by bin/rails g.

# config/environments/development.rb
Rails.application.configure do
  config.generators.after_generate do |files|
    parsable_files = files.filter { |file| file.end_with?('.rb') }
    unless parsable_files.empty?
      system("bundle exec rubocop -A --fail-level=E #{parsable_files.shelljoin}", exception: true)
    end
  end
end

It uses rubocop -A to apply Style/FrozenStringLiteralComment and other unsafe autocorrection cops.
rubocop -A is unsafe autocorrection, but code generated by default is simple and less likely to
be incompatible with rubocop -A. If you have problems you can replace it with rubocop -a instead.

In Rails 7.2+, it is recommended to use config.generators.apply_rubocop_autocorrect_after_generate! instead of the above setting:

 # config/environments/development.rb
 Rails.application.configure do
   (snip)
   # Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
-  # config.generators.apply_rubocop_autocorrect_after_generate!
+  config.generators.apply_rubocop_autocorrect_after_generate!
 end

You only need to uncomment.

The Cops

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

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

Rails/FindBy:
  Exclude:
    - lib/example.rb

Documentation

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

Compatibility

Rails cops support the following versions:

  • Rails 4.2+

Readme Badge

If you use RuboCop Rails in your project, you can include one of these badges in your readme to let people know that your code is written following the community Rails Style Guide.

Rails Style Guide

Rails Style Guide

Here are the Markdown snippets for the two badges:

[![Rails Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop-rails)

[![Rails Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rails.rubystyle.guide)

Contributing

Checkout the contribution guidelines.

License

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


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 8 days ago

Total Commits: 1,768
Total Committers: 270
Avg Commits per committer: 6.548
Development Distribution Score (DDS): 0.504

Commits in past year: 127
Committers in past year: 19
Avg Commits per committer in past year: 6.684
Development Distribution Score (DDS) in past year: 0.417

Name Email Commits
Koichi ITO k****o@g****m 877
Earlopain 1****n 56
fatkodima f****3@g****m 49
r7kamura r****a@g****m 39
Ted Johansson d****i@g****m 36
Masataka Pocke Kuwabara k****a@p****e 35
Ryan Rosenblum r****m@g****m 31
Eugene Kenny e****y@g****m 24
Bozhidar Batsov b****r@t****m 21
Bozhidar Batsov b****r@b****m 20
wata_mac w****s@g****m 20
John Backus j****s@g****m 19
Benjamin Quorning b****n@q****t 19
ydah 1****h 17
Tejas Bubane t****e@g****m 17
viralpraxis i****k@g****m 14
masato-bkn 3****n 14
Andy Waite a****8 12
palkan d****m@g****m 10
Garett Arrowood g****d@g****m 9
Phil Pirozhkov h****o@f****u 9
David Rodríguez d****z@g****m 8
Yauheni Dakuka y****a@g****m 8
Sunny Ripert s****y@s****g 8
hoshinotsuyoshi g****0@g****m 7
Alex Dowad a****g@g****m 7
sinsoku s****y@g****m 7
Daniel Vandersluis d****s@g****m 6
Jonas Arvidsson j****4@g****m 6
Teemu t****u@a****n 6
and 240 more...

Committer domains:


Issue and Pull Request metadata

Last synced: 30 days ago

Total issues: 308
Total pull requests: 497
Average time to close issues: 6 months
Average time to close pull requests: 3 months
Total issue authors: 209
Total pull request authors: 96
Average comments per issue: 1.67
Average comments per pull request: 1.36
Merged pull request: 358
Bot issues: 0
Bot pull requests: 3

Past year issues: 52
Past year pull requests: 113
Past year average time to close issues: 9 days
Past year average time to close pull requests: 3 days
Past year issue authors: 44
Past year pull request authors: 29
Past year average comments per issue: 0.73
Past year average comments per pull request: 0.65
Past year merged pull request: 69
Past year bot issues: 0
Past year bot pull requests: 1

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/rubocop/rubocop-rails

Top Issue Authors

  • ydakuka (53)
  • fatkodima (8)
  • vlad-pisanov (5)
  • Earlopain (5)
  • tagliala (4)
  • bquorning (4)
  • akimd (3)
  • andyw8 (3)
  • JasonBarnabe (3)
  • schinery (3)
  • Splines (2)
  • viralpraxis (2)
  • Uaitt (2)
  • hirowatari (2)
  • phil-workato (2)

Top Pull Request Authors

  • koic (100)
  • Earlopain (89)
  • fatkodima (37)
  • masato-bkn (26)
  • r7kamura (24)
  • viralpraxis (21)
  • ydakuka (20)
  • lovro-bikic (6)
  • tldn0718 (6)
  • sambostock (6)
  • ccutrer (6)
  • eugeneius (6)
  • dvandersluis (5)
  • vlad-pisanov (5)
  • tejasbubane (5)

Top Issue Labels

  • bug (57)
  • enhancement (32)
  • feature request (15)
  • duplicate (9)
  • documentation (2)
  • good first issue (1)

Top Pull Request Labels

  • dependencies (3)
  • github_actions (1)

Package metadata

gem.coop: rubocop-rails

Automatic Rails code style checking tool. A RuboCop extension focused on enforcing Rails best practices and coding conventions.

  • Homepage: https://docs.rubocop.org/rubocop-rails/
  • Documentation: http://www.rubydoc.info/gems/rubocop-rails/
  • Licenses: MIT
  • Latest release: 2.34.3 (published about 2 months ago)
  • Last Synced: 2026-02-22T04:00:40.784Z (9 days ago)
  • Versions: 88
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 259,752,273 Total
  • Docker Downloads: 702,290,956
  • Rankings:
    • Dependent repos count: 0.0%
    • Dependent packages count: 0.0%
    • Average: 0.059%
    • Downloads: 0.103%
    • Docker downloads count: 0.132%
  • Maintainers (2)
rubygems.org: rubocop-rails

Automatic Rails code style checking tool. A RuboCop extension focused on enforcing Rails best practices and coding conventions.

  • Homepage: https://docs.rubocop.org/rubocop-rails/
  • Documentation: http://www.rubydoc.info/gems/rubocop-rails/
  • Licenses: MIT
  • Latest release: 2.34.3 (published about 2 months ago)
  • Last Synced: 2026-02-22T02:23:53.441Z (9 days ago)
  • Versions: 88
  • Dependent Packages: 529
  • Dependent Repositories: 15,268
  • Downloads: 259,748,758 Total
  • Docker Downloads: 702,290,956
  • Rankings:
    • Dependent packages count: 0.09%
    • Downloads: 0.123%
    • Docker downloads count: 0.178%
    • Dependent repos count: 0.285%
    • Average: 0.754%
    • Forks count: 1.739%
    • Stargazers count: 2.109%
  • Maintainers (2)
proxy.golang.org: github.com/rubocop/rubocop-rails

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/rubocop/rubocop-rails#section-documentation
  • Licenses: mit
  • Latest release: v2.34.3+incompatible (published about 2 months ago)
  • Last Synced: 2026-02-22T02:23:56.371Z (9 days ago)
  • Versions: 208
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Dependent packages count: 6.508%
    • Average: 6.726%
    • Dependent repos count: 6.945%

Dependencies

.github/workflows/linting.yml actions
  • actions/checkout v3 composite
  • karancode/yamllint-github-action master composite
.github/workflows/spell_checking.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
Gemfile rubygems
  • bump >= 0
  • rake >= 0
  • rspec >= 0
  • rubocop >= 0
  • rubocop-performance ~> 1.15.0
  • rubocop-rspec ~> 2.16.0
  • simplecov >= 0
  • test-queue >= 0
  • yard ~> 0.9
rubocop-rails.gemspec rubygems
  • activesupport >= 4.2.0
  • rack >= 1.1
  • rubocop >= 1.33.0, < 2.0

Score: 33.91830276314337