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

Opting-out of cops at the command line #1430

Closed
fj opened this issue Nov 4, 2014 · 6 comments
Closed

Opting-out of cops at the command line #1430

fj opened this issue Nov 4, 2014 · 6 comments

Comments

@fj
Copy link

fj commented Nov 4, 2014

I'd like a way to say:

  • run lint checks
  • run all the other cops, except this list

IOW, I was looking for something like, e.g.:

rubocop --lint --except Style/Tab,Style/ConstantName,Metrics/CyclomaticComplexity

Right now the workaround I've been using is to use --only with a very long list in a Rake task, but that's not very maintainable.

You can also do this via a configuration file. But it's much easier to specify these at the command line for things like, e.g., special Rake tasks and CI runs -- that's nice because you're documenting the arguments in the same spot as where you're invoking Rubocop. When you use a configuration file, you have to check two places instead of one.

@bbatsov
Copy link
Collaborator

bbatsov commented Nov 13, 2014

run all the other cops, except this list

By "all the cops" you mean all cops that are enabled in the config, right?

@fj
Copy link
Author

fj commented Nov 13, 2014

Right, all enabled cops (they're all enabled by default, right?).

@jonas054
Copy link
Collaborator

If you want to run all (enabled) cops except a specified list, then the lint cops will be included. You don't need --lint. And even though we don't support an --except option, it's pretty simple to put the list in a configuration file:

rubocop --config except.yml
# except.yml
inherit_from: .rubocop.yml

Style/Tab:
  Enabled: false

Style/ConstantName:
  Enabled: false

Metrics/CyclomaticComplexity:
  Enabled: false

@fj fj changed the title Opting-out of cops Opting-out of cops at the command line Nov 14, 2014
@fj
Copy link
Author

fj commented Nov 14, 2014

@jonas054 I don't think my issue title was specific enough; I agree that you can do this via a configuration file. But it's much easier to specify these at the command line for things like, e.g., special Rake tasks and CI runs -- that's nice because you're documenting the arguments in the same spot as where you're invoking Rubocop. When you use a configuration file, you have to check two places instead of one.

@jonas054
Copy link
Collaborator

If someone wants to add an --except option, I'd be fine with it. Not sure if I have time to do it myself, but I think it makes sense to have it.

bbatsov added a commit that referenced this issue Dec 14, 2014
[Fix #1430] Add option --except for disabling cops on command line
@fj
Copy link
Author

fj commented Dec 15, 2014

Thanks @jonas054! 👍 ✖️ 💯

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

3 participants