No release in over a year
RuboCop configuration which has the same code style checking as official Ruby on Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

rubocop-rails_config

Gem Version Test

RuboCop configuration which has the same code style checking as official Ruby on Rails.

Official RoR RuboCop Configuration

Installation

Add this line to your application's Gemfile:

gem "rubocop-rails_config"

Usage

Add this line to your application's .rubocop.yml:

inherit_gem:
  rubocop-rails_config:
    - config/rails.yml

Or just run:

$ rails generate rubocop_rails_config:install

Configuration

TargetRubyVersion

If you'd like to change TargetRubyVersion, see 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.

class AssertNotTest < ActiveSupport::TestCase
  def test_assert_not_method
    assert_not ...(code)...
  end

  def test_assert_not_nil_method
    assert_not_nil ...(code)...
  end
end

See also. ActiveSupport::Testing::Assertions

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:

# .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.