Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/toshimaru/rubocop-rails_config
RuboCop configuration which has the same code style checking as official Ruby on Rails.
https://github.com/toshimaru/rubocop-rails_config
gem rails rubocop
Last synced: 6 days ago
JSON representation
RuboCop configuration which has the same code style checking as official Ruby on Rails.
- Host: GitHub
- URL: https://github.com/toshimaru/rubocop-rails_config
- Owner: toshimaru
- License: mit
- Created: 2018-06-20T16:11:43.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-05-16T11:59:13.000Z (9 months ago)
- Last Synced: 2025-01-17T18:16:55.797Z (13 days ago)
- Topics: gem, rails, rubocop
- Language: Ruby
- Homepage:
- Size: 233 KB
- Stars: 155
- Watchers: 6
- Forks: 19
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# rubocop-rails_config
[![Gem Version](https://badge.fury.io/rb/rubocop-rails_config.svg)](https://badge.fury.io/rb/rubocop-rails_config)
![Test](https://github.com/toshimaru/rubocop-rails_config/workflows/Test/badge.svg)RuboCop configuration which has the same code style checking as official Ruby on Rails.
[Official RoR RuboCop Configuration](https://github.com/rails/rails/blob/main/.rubocop.yml)
## Installation
Add this line to your application's `Gemfile`:
```ruby
gem "rubocop-rails_config"
```## Usage
Add this line to your application's `.rubocop.yml`:
```yml
inherit_gem:
rubocop-rails_config:
- config/rails.yml
```Or just run:
```console
$ rails generate rubocop_rails_config:install
```## Configuration
### TargetRubyVersion
If you'd like to change `TargetRubyVersion`, see [Customization](#customization).
### Rails/AssertNot, Rails/RefuteMethods
| cop | description |
| --- | --- |
| `Rails/AssertNot` | Prefer assert_not over assert |
| `Rails/RefuteMethods` | Prefer assert_not_x over refute_x |`assert_not` and `assert_not_xxx` methods are Rails assertion extension, so if you want to use these methods, require `activesupport` gem and inherit `ActiveSupport::TestCase`.
```rb
class AssertNotTest < ActiveSupport::TestCase
def test_assert_not_method
assert_not ...(code)...
enddef test_assert_not_nil_method
assert_not_nil ...(code)...
end
end
```See also. [ActiveSupport::Testing::Assertions](https://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html)
## Customization
If you'd like to customize the rubocop setting on your project, you can override it.
For example, if you want to change `TargetRubyVersion`, you can do it like:
```yml
# .rubocop.yml
inherit_gem:
rubocop-rails_config:
- config/rails.yml# Override Setting
AllCops:
TargetRubyVersion: 3.0
```This overrides `config/rails.yml` setting with `TargetRubyVersion: 3.0`.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).