Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Rails Style Guide | 6,365 | 2 months ago | 19 | |||||||
A community-driven Ruby on Rails style guide | ||||||||||
Rubocop Rails | 712 | 537 | 380 | a day ago | 63 | July 07, 2022 | 113 | mit | Ruby | |
A RuboCop extension focused on enforcing Rails best practices and coding conventions. | ||||||||||
Souls | 329 | 7 months ago | 733 | October 14, 2022 | 3 | apache-2.0 | Ruby | |||
SOULs 🔥 Build Serverless Apps faster like Rails. Powered by Ruby GraphQL, Active Record, RSpec, RuboCop, and Google Cloud. | ||||||||||
Rails Base | 189 | a year ago | 15 | Ruby | ||||||
Skeleton for new Rails based projects. | ||||||||||
Expertiza | 177 | a month ago | 135 | mit | Ruby | |||||
Expertiza is a web application through which students can submit and peer-review learning objects (articles, code, web sites, etc). The Expertiza project is supported by the National Science Foundation. | ||||||||||
Kitsu Server | 175 | 3 days ago | 27 | apache-2.0 | Ruby | |||||
:steam_locomotive: Rails API server for Kitsu | ||||||||||
Granite | 158 | 1 | 2 months ago | 29 | January 31, 2023 | 3 | mit | Ruby | ||
Business Actions architecture for Rails apps | ||||||||||
Rubocop Rails_config | 149 | 64 | 63 | a month ago | 102 | January 14, 2023 | 2 | mit | Ruby | |
RuboCop configuration which has the same code style checking as official Ruby on Rails. | ||||||||||
Devise Doorkeeper Cancan Api Example | 124 | 6 years ago | Ruby | |||||||
rails 4, rails-api, devise, doorkeeper, oauth, cancancan, rspec, puma, vcr, factory_girl, reqres_rspec, pg, dotenv, rack-cors, active_model_serializers, rubocop | ||||||||||
Rubocop Linter Action | 81 | 3 years ago | n,ull | mit | Ruby | |||||
Rubocop Linter Action: A GitHub Action to run Rubocop against your code! |
A RuboCop extension focused on enforcing Rails best practices and coding conventions.
Note: This repository manages rubocop-rails gem (>= 2.0.0). rubocop-rails gem (<= 1.5.0) has been renamed to rubocop-rails_config gem.
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
You need to tell RuboCop to load the Rails extension. There are three ways to do this:
Put this into your .rubocop.yml
.
require: rubocop-rails
Alternatively, use the following array notation when specifying multiple extensions.
require:
- rubocop-other-extension
- rubocop-rails
Now you can run rubocop
and it will automatically load the RuboCop Rails
cops together with the standard cops.
$ rubocop --require rubocop-rails
Note: --rails
option is required while rubocop
command supports --rails
option.
RuboCop::RakeTask.new do |task|
task.requires << 'rubocop-rails'
end
If you are using Rails 6.1 or newer, add the following config.generators.after_generate
setting to
your config/application.rb to apply RuboCop autocorrection to code generated by bin/rails g
.
# config/application.rb
module YourCoolApp
class Application < Rails::Application
config.generators.after_generate do |files|
parsable_files = files.filter { |file| file.end_with?('.rb') }
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 autocorretion 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.
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
You can read a lot more about RuboCop Rails in its official docs.
Rails cops support the following versions:
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)
Checkout the contribution guidelines.
rubocop-rails
is MIT licensed. See the accompanying file for
the full text.