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.
- Host: GitHub
- URL: https://github.com/rubocop/rubocop-rails
- Owner: rubocop
- License: mit
- Created: 2018-06-10T05:22:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2026-02-14T01:12:30.000Z (17 days ago)
- Last Synced: 2026-02-27T02:14:34.071Z (4 days ago)
- Topics: code-formatter, hacktoberfest, linter, rails, rubocop, ruby, static-code-analysis
- Language: Ruby
- Homepage: https://docs.rubocop.org/rubocop-rails
- Size: 28.2 MB
- Stars: 860
- Watchers: 13
- Forks: 291
- Open Issues: 175
- Releases: 88
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
README.md
RuboCop Rails
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, userequireinstead ofplugins.
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.
Here are the Markdown snippets for the two badges:
[](https://github.com/rubocop/rubocop-rails)
[](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
- Name: RuboCop Headquarters
- Login: rubocop
- Email:
- Kind: organization
- Description: We're committed to promoting the best Ruby programming practices and helping people write better Ruby applications.
- Website: https://rubocop.org
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/10871348?v=4
- Repositories: 28
- Last ynced at: 2024-03-25T19:40:52.798Z
- Profile URL: https://github.com/rubocop
GitHub Events
Total
- Release event: 14
- Delete event: 1
- Pull request event: 168
- Fork event: 20
- Issues event: 100
- Watch event: 45
- Issue comment event: 194
- Push event: 136
- Pull request review event: 105
- Pull request review comment event: 102
- Create event: 13
Last Year
- Release event: 10
- Delete event: 1
- Pull request event: 106
- Fork event: 12
- Issues event: 67
- Watch event: 23
- Issue comment event: 129
- Push event: 87
- Pull request review event: 59
- Pull request review comment event: 58
- Create event: 9
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 | 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:
- shopify.com: 4
- github.com: 2
- gitlab.com: 2
- cookpad.com: 2
- toptal.com: 2
- infinum.hr: 2
- gusto.com: 2
- mail.gvsu.edu: 1
- cashbee.fr: 1
- viget.com: 1
- fidor.de: 1
- onemedical.com: 1
- thanx.com: 1
- practicefusion.com: 1
- andpad.co.jp: 1
- ojab.ru: 1
- tobiasmaier.info: 1
- muehl.dev: 1
- trux.info: 1
- truelinkfinancial.com: 1
- andela.co: 1
- salsify.com: 1
- fusioneer.com: 1
- challengepost.com: 1
- hatchinvest.nz: 1
- opencorporates.com: 1
- doma.io: 1
- marleyspoon.com: 1
- redhat.com: 1
- tinkerbox.com.sg: 1
- pocke.me: 1
- tradeo.com: 1
- batsov.com: 1
- quorning.net: 1
- fili.pp.ru: 1
- sunfox.org: 1
- aikais.in: 1
- hardscrabble.net: 1
- nilsgemeinhardt.de: 1
- quinnharris.me: 1
- dana.sh: 1
- raylo.com: 1
- chime.com: 1
- lengemann.net: 1
- leoarnold.de: 1
- betterment.com: 1
- justincoyne.com: 1
- instructure.com: 1
- anthony-robin.fr: 1
- tanda.co: 1
- logicminds.biz: 1
- splitwise.com: 1
- umich.edu: 1
- jankowski.online: 1
- cyt.ch: 1
- urbanautomaton.com: 1
- yahoo.co.jp: 1
- soutaro.com: 1
- squareup.com: 1
- me.com: 1
- fmail.co.uk: 1
- seznam.cz: 1
- radicaos.com: 1
- annkissam.com: 1
- jaredbeck.com: 1
- betterplace.org: 1
- mutan.io: 1
- herbert.id: 1
- nevir.net: 1
- dio.jp: 1
- blockscore.com: 1
- dtho.mp: 1
- riseup.net: 1
- oboxodo.com: 1
- joshpeek.com: 1
- mccarthy.vg: 1
- gifthealth.com: 1
- digital.cabinet-office.gov.uk: 1
- synergiaconsultoria.com.br: 1
- markusgraf.ch: 1
- sue445.net: 1
- rodas.mx: 1
- jetbuilt.com: 1
- cardflight.com: 1
- masterclass.com: 1
- renuo.ch: 1
- aluno.unb.br: 1
- johnsy.com: 1
- yandex.ru: 1
- leitzen.de: 1
- fleetio.com: 1
- philip.in-aachen.net: 1
- mcgeary.org: 1
- segiddins.me: 1
- joinhandshake.com: 1
- simplelogin.co: 1
- telhaug.no: 1
- matijs.net: 1
- grosser.it: 1
- procore.com: 1
- makandra.de: 1
- promisedlandt.de: 1
- buffon.dev: 1
- codez.ch: 1
- mail.ru: 1
- smarthr.co.jp: 1
- paulisageek.com: 1
- hey.com: 1
- blue-pixel.info: 1
- tutanota.de: 1
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
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
- Total packages: 3
-
Total downloads:
- rubygems: 519,501,031 total
- Total docker downloads: 1,404,581,912
- Total dependent packages: 529 (may contain duplicates)
- Total dependent repositories: 15,268 (may contain duplicates)
- Total versions: 384
- Total maintainers: 2
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
- actions/checkout v3 composite
- karancode/yamllint-github-action master composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- 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
- activesupport >= 4.2.0
- rack >= 1.1
- rubocop >= 1.33.0, < 2.0
Score: 33.91830276314337