Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use the --only option with custom cop settings to run only rubocop-rails #9251

Closed
mensfeld opened this issue Dec 18, 2020 · 2 comments · Fixed by #9253
Closed

Cannot use the --only option with custom cop settings to run only rubocop-rails #9251

mensfeld opened this issue Dec 18, 2020 · 2 comments · Fixed by #9253
Labels

Comments

@mensfeld
Copy link

When attempting to run only certain department cops form rubocop-rails using the rubocop --only flag, I get following error:

Error: `Rails/*` has been extracted to the `rubocop-rails` gem.
(obsolete configuration found in .rubocop.yml, please update it)

Expected behavior

It should allow me to run Rails cops only with one of them being disabled but the rest of the department working.

Actual behavior

Fails

Steps to reproduce the problem

# Gemfile
source 'https://rubygems.org'

gem 'rubocop-rails'
# .rubocop.yml

AllCops:
  Exclude:
    - bin/**/*
    - db/schema.rb
    - .gemspec/**/*
    - .bundle/**/*
    - vendor/**/*
    - '**/dummy**/*'
    - !ruby/regexp /old_and_unused\.rb$/

Rails/NotNullColumn:
  Enabled: false
# Shell command I use to run it

bundle exec rubocop --only Rails -- require rubocop-rails

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler.
If you see extension cop versions (e.g. rubocop-performance, rubocop-rspec, and others)
output by rubocop -V, include them as well. Here's an example:

rubocop -V
1.6.1 (using Parser 2.7.2.0, rubocop-ast 1.3.0, running on ruby 2.7.1 x86_64-linux)
[test]$ rubocop -v
@koic
Copy link
Member

koic commented Dec 18, 2020

Thank you for your feedback. A workaround is to change require rubocop-rails from command line argument to .rubocop.yml config.

+require: rubocop-rails

 AllCops:
   Exclude:
     - bin/**/*
     - db/schema.rb
     - .gemspec/**/*
     - .bundle/**/*
     - vendor/**/*
     - '**/dummy**/*'
     - !ruby/regexp /old_and_unused\.rb$/

 Rails/NotNullColumn:
   Enabled: false

I'll transfer the issue to the core because it is related to #9169.

@koic koic transferred this issue from rubocop/rubocop-rails Dec 18, 2020
@koic koic added the bug label Dec 18, 2020
@dvandersluis
Copy link
Member

I'm on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants