GithubHelp home page GithubHelp logo

toshimaru / rubocop-rails_config Goto Github PK

View Code? Open in Web Editor NEW
152.0 6.0 23.0 231 KB

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

License: MIT License

Ruby 100.00%
rubocop rails gem

rubocop-rails_config's Introduction

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.

rubocop-rails_config's People

Contributors

floppy avatar gnomus avatar grimmxsleeper avatar koic avatar phantom-as avatar toshimaru avatar utkarsh2102 avatar willnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rubocop-rails_config's Issues

Target Ruby Version 2.5

As of Rails 6, Ruby 2.4 or more is required and rubocop.yml is also configured to use Ruby 2.4.

Ruby2.4 should be used in this project, but I think it’s too early to use Ruby 2.4 because there might be many Ruby 2.3 users.

It’d be good time to update to Ruby 2.4 when Rails 6 is generally available.

bug in new version rubocop 0.68

$gem install rubocop

Performance Cops will be removed from RuboCop 0.68. Use rubocop-performance gem instead.

Put this in your Gemfile.

gem 'rubocop-performance'

And then execute:

$ bundle install

Put this into your .rubocop.yml.

require: rubocop-performance

More information: https://github.com/rubocop-hq/rubocop-performance
Successfully installed rubocop-0.68.1
Parsing documentation for rubocop-0.68.1
Done installing documentation for rubocop after 4 seconds
1 gem installed

and if RUN rubocop in project folder
$ rubocop
Error: The Layout/FirstParameterIndentation cop has been renamed to Layout/IndentFirstArgument.
(obsolete configuration found in /home/pavel/.rvm/gems/ruby-2.6.2/gems/rubocop-rails_config-0.5.1/config/rails.yml, please update it)

Exclude Gemfile.lock.

Using VSCode and this plugin everything works except this:

AllCops:
  TargetRubyVersion: 2.5
  Exclude:
    - Gemfile.lock

Why?

rubocop-rails_config 1.0

rubocop-rails_config complies with .rubocop.yml in the rails/rails repository, so the APIs is stable for users.
Therefore, I think that rubocop-rails_config can be versioned to 1.0. What do you think about it?

Error: obsolete `EnforcedStyle: rails`

As of rubocop v0.72.0:

Error: obsolete `EnforcedStyle: rails` (for Layout/IndentationConsistency) found in vendor/bundle/ruby/2.5.0/gems/rubocop-rails_config-0.6.2/config/rails.yml
`EnforcedStyle: rails` has been renamed to `EnforcedStyle: indented_internal_methods`

Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: rails

rubocop-rails_config is not compatible with rubocop 0.76.0

Error message:

Error: The `Style/UnneededPercentQ` cop has been renamed to `Style/RedundantPercentQ`.
(obsolete configuration found in /opt/hostedtoolcache/Ruby/2.6.3/x64/lib/ruby/gems/2.6.0/gems/rubocop-rails_config-0.7.2/config/rails.yml, please update it)

rubocop v0.77.0 breaking changes

After bumping rubocop from 0.76.0 to 0.77.0:

Error: The `Layout/IndentFirstArgument` cop has been renamed to `Layout/FirstArgumentIndentation`.
(obsolete configuration found in /opt/hostedtoolcache/Ruby/2.6.3/x64/lib/ruby/gems/2.6.0/gems/rubocop-rails_config-0.8.1/config/rails.yml, please update it)
The `Layout/TrailingBlankLines` cop has been renamed to `Layout/TrailingEmptyLines`.
(obsolete configuration found in /opt/hostedtoolcache/Ruby/2.6.3/x64/lib/ruby/gems/2.6.0/gems/rubocop-rails_config-0.8.1/config/rails.yml, please update it)
The `Lint/StringConversionInInterpolation` cop has been renamed to `Lint/RedundantStringCoercion`.
(obsolete configuration found in /opt/hostedtoolcache/Ruby/2.6.3/x64/lib/ruby/gems/2.6.0/gems/rubocop-rails_config-0.8.1/config/rails.yml, please update it)

related: rails/rails#37821

Customization doesn't work

For example, it is impossible to disable Layout/IndentationConsistency cop

Layout/IndentationConsistency:
  Enabled: False

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.