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

How to disable all cops except some #1918

Closed
victorteokw opened this issue May 25, 2015 · 17 comments
Closed

How to disable all cops except some #1918

victorteokw opened this issue May 25, 2015 · 17 comments

Comments

@victorteokw
Copy link

No description provided.

@jonas054
Copy link
Collaborator

You use the --only command line option. For example

rubocop --only Metrics
rubocop --only Style/FormatString,Style/HashSyntax

@bbatsov bbatsov closed this as completed May 26, 2015
@victorteokw
Copy link
Author

Thanks, but how to do it with config file?

@jonas054
Copy link
Collaborator

I'm not sure why you would want to do that exactly, but the normal workflow when starting to use RuboCop is to run rubocop --auto-gen-config, then add inherit_from: .rubocop_todo.yml in .rubocop.yml. It achieves the same goal as disabling all cops, except that the cops that have not found any offenses remain enabled.

@jbodah
Copy link

jbodah commented May 29, 2015

I was wondering the same thing. I don't want to inherit all of the default style checks that Rubocop provides by default and would much rather just specify the things we want rather than have to keep going back in to override things. It would be great to be able to just disable_defaults: true or something in the config

@jbodah
Copy link

jbodah commented May 29, 2015

Tried messing around in a fork a bit to see if we can just get rid of the default config, but it looks like we're expecting configuration values to be present for all the cops (as opposed to reading the configs and only loading cops that are declared)

https://github.com/backupify/rubocop/pull/1

@jonas054
Copy link
Collaborator

Opening this issue again to make a pull request with a solution.

@jonas054 jonas054 reopened this Jun 26, 2015
@victorteokw
Copy link
Author

👍

@jbodah
Copy link

jbodah commented Jun 26, 2015

Sweet thanks!

bbatsov added a commit that referenced this issue Jun 27, 2015
[Fix #1918] Add config param AllCops:DisabledByDefault
@tisba
Copy link

tisba commented Jul 30, 2015

This is a great feature, thanks! Is there any ETA on the upcoming release containing this?

@pschambacher
Copy link

It would actually be nice to have the same option for each category. I'm interested in everything except all the Style/

@jonas054
Copy link
Collaborator

jonas054 commented Nov 5, 2016

@pschambacher This issue talks about a few different options, so can you clarify a bit what it is that you want?

@pschambacher
Copy link

@jonas054 this is what I was thinking about:

AllCops:
  DisableByDefault: false

Style/AllCops:
  DisableByDefault: true

This way I get all existing (and future) cops enabled except for any existing (and future) Style cops.
Making it the other way around would be "I only care for Style cops"

@jonas054
Copy link
Collaborator

jonas054 commented Nov 9, 2016

That's a good idea. But the syntax should be

Style:
  DisableByDefault: true

Currently, such a setting is silently ignored, which is clearly not what we want.

@pschambacher
Copy link

I'm completely fine with this syntax :)

@chadxz
Copy link

chadxz commented Dec 28, 2016

I came looking for

Metrics:
  DisableByDefault: true

and found this ticket. is anyone working on it?

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 28, 2016

Most likely no.

@wangsitan
Copy link

wangsitan commented Aug 24, 2023

For people get here later and interested in this, you can find doc at:
https://docs.rubocop.org/rubocop/configuration.html#generic-configuration-parameters

What you want may look like this:

AllCops:
  DisabledByDefault: true
  
Style:
  Enabled: true

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

No branches or pull requests

8 participants