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

RuboCop warns "The following cops were added to RuboCop, but are not configured." #7771

Closed
roberts1000 opened this issue Mar 2, 2020 · 26 comments
Labels

Comments

@roberts1000
Copy link
Contributor

When I run RuboCop 0.80.1 I get the following output:

$ rubocop
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file:
 - Style/HashEachMethods (0.80)
 - Style/HashTransformKeys (0.80)
 - Style/HashTransformValues (0.80)
For more information: https://docs.rubocop.org/en/latest/versioning/
Inspecting 330 files
.C..............................................................................................................................................................
...............................................................................................C................................................................
..........

Expected behavior

I expected the output to not include a warning about missing configuration.

Actual behavior

See the above output.

Steps to reproduce the problem

Install RuboCop 0.80.1 and execute rubocop. I have a .rubocop.yml file in my project. It has a bunch of configuration in it, but the contents don't seem to matter. If I comment-out everything in the file, I still get the above output. However, if I rename .rubocop.yml to .rubocop.yml.bak and run, the warning output goes away.

RuboCop version

$ [bundle exec] rubocop -V
0.80.1 (using Parser 2.7.0.4, running on ruby 2.6.5 x86_64-linux)
@bbatsov
Copy link
Collaborator

bbatsov commented Mar 2, 2020

Well, the message tells you what you need to do - either mark those cops as enabled or disabled in your config. Check the documentation link from the message for more details.

@roberts1000
Copy link
Contributor Author

roberts1000 commented Mar 2, 2020

Why is this necessary now? My config only adjusts a couple cops. Shouldn't those cops be enabled/disabled in a default config inside RuboCop?

@vaporyhumo
Copy link
Contributor

vaporyhumo commented Mar 2, 2020

@roberts1000 new cops are introduced this way so you can take your decision on what to do with them. If they were enabled by default they might break your integration; if they weren't you might never notice them.

@Drenmi Drenmi added the question label Mar 3, 2020
benthorner pushed a commit to alphagov/rubocop-govuk that referenced this issue Mar 12, 2020
Related issue: rubocop/rubocop#7771

We should enable these cops until we have a good reason not to.
benthorner pushed a commit to alphagov/rubocop-govuk that referenced this issue Mar 12, 2020
Related issue: rubocop/rubocop#7771

We should enable these cops until we have a good reason not to.
@afdev82
Copy link

afdev82 commented Mar 17, 2020

Yes, I had the same for the cop HashEachMethods and after enabling it I got the same as in this issue that was closed.

@hirowatari
Copy link

I've read the documentation here: https://docs.rubocop.org/en/latest/versioning/, but still am not clear on a couple things.

  1. The docs talk about enabling pending cops after the next major release. I assume that won't be until 1.0.0. Is that true?
  2. Will there also be a warning that I've enabled a bunch of cops that are now the default, once they are the default. Or is there a way to deal with this potential mess.

@bbatsov
Copy link
Collaborator

bbatsov commented Mar 20, 2020

The docs talk about enabling pending cops after the next major release. I assume that won't be until 1.0.0. Is that true?

Yes. 1.0 is pretty close, btw. Even the next release might 1.0 as far as I'm concerned. Wanted to do a bit more for it, but given the current situation we'll probably scale back the plans.

Will there also be a warning that I've enabled a bunch of cops that are now the default, once they are the default. Or is there a way to deal with this potential mess.

There won't a warning then. If you enabled something explicitly RuboCop doesn't care whether it's enabled by default or not.

@hirowatari
Copy link

Thanks @bbatsov. And thanks for all your work on this gem.

@JEVBR
Copy link

JEVBR commented Mar 24, 2020

+/- Same issue here, Cop was just started ignoring all errors but showing the popup in VScode. this after working flawless for a long time.

Fixed it by deleting the rubocop.yml, uninstalling and re-installing the rubocop vscode plugin

@swrobel
Copy link
Contributor

swrobel commented Apr 5, 2020

Is there a setting to auto-enable all pending cops without having to add them individually to my config (basically bring back the old behavior)?

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 5, 2020

@swrobel Not yet, but we'll likely add this pretty soon.

@fonji
Copy link

fonji commented Apr 5, 2020

Well, meanwhile, there kind of is a way :

AllCops:
  EnabledByDefault: true

I requires some work on your configuration, as you have to manually disable all cops that are disabled by default. We took this opportunity to make a big review and enable a few more cops.

@madlew
Copy link

madlew commented Apr 7, 2020

I'm missing consistency here. I bumped from 0.80 to 0.81 and got the following message:

The following cops were added to RuboCop, but are not configured. Please set Enabled to either true or false in your .rubocop.yml file:

  • Lint/RaiseException (0.81)
  • Lint/StructNewOverride (0.81)
  • Style/HashEachMethods (0.80)
  • Style/HashTransformKeys (0.80)
  • Style/HashTransformValues (0.80)

so I see there are two new cops in version 0.81 but changelog https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md#0810-2020-04-01 says there are 4 new cops.. so why don't we have all four listed in the output notice?
Also, does it mean that 2 new cops not listed here, i.e.:

  • Style/TrailingCommaInBlockArgs
  • Style/DisableCopsWithinSourceCodeDirective
    are enabled by default?

This is simply confusing.

@madlew
Copy link

madlew commented Apr 7, 2020

Btw. before rubocop 0.80.1 we could minimize our rubocop configuration to only some exceptions to what's enabled and set by default. It was convenient, helped to follow the community rules, keep the configuration small etc. This change forces us to keep extending our project rubocop configuration, which over time will make it more and more complex. Is it what you'd like to have in your projects?

I read that this change was introduced because some ppl complained about failing CI builds after a rubocop upgrade. Maybe this is not the full picture but from my point of view you can always disable a new cop or re-generate rubocop_todo - it's just part of the upgrade job. Some bugfixes might also break CI but are not disabled by default like new cops. I don't get what's the point of this feature - to help someone do an upgrade without the upgrade? If someone is not ready to do an upgrade or has no time to work on it, he/she should simply not do it and that's it.

To recap: I'm sorry but I'm not a fan of this change.

Fortunately there's a way to bring back the old strategy by adding:

AllCops:
NewCops: enable

which I'd make default

@madlew
Copy link

madlew commented Apr 7, 2020

oh wait..

Warning: AllCops does not support NewCops parameter.

though https://docs.rubocop.org/en/latest/versioning suggests adding

AllCops:
  NewCops: enable

so what am I doing wrong? Yet another confusion :/
Fortunately

AllCops:
  EnabledByDefault: true

works as expected.

@swrobel
Copy link
Contributor

swrobel commented Apr 7, 2020

@madlew please dial it back. This is not a support forum; this is the issue tracker for an OSS project. I realize you're experiencing frustration with a (free) tool that you depend on (as was I) but there are productive (as well as unproductive) ways to go about expressing that. The rubocop team has worked very quickly to resolve this (kudos @koic!)

A quick skim of the changelog reveals that the NewCops option is unreleased, but will be included in the next rubocop version. You can use rubocop from github for now if you urgently need this setting.

@madlew
Copy link

madlew commented Apr 7, 2020

My intention was to help by sharing feedback about a user (probably not only mine) experience.
I thought this is 'Rubocop issues..' section where ppl describe issues.. If this is not the right place to share my feedback, where is the right one?

and btw. you don't have to convince me that the rubocop team is doing great job.

@swrobel
Copy link
Contributor

swrobel commented Apr 7, 2020

@madlew seriously, this project is so well-documented, if you would just take a second to do the research for yourself instead of continuing to ask here, you could easily find the answer! I'm going to stop spamming everyone on this thread, so this will be my last response.

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 7, 2020

says there are 4 new cops.. so why don't we have all four listed in the output notice?
Also, does it mean that 2 new cops not listed here, i.e.:
This is simply confusing.

Seems we made a mistake and enabled a couple of cops by accident. Sorry about that!

@stephenwade
Copy link

AllCops:
  NewCops: enable

This now works with rubocop 0.83.0.

@jmbuscemi
Copy link

jmbuscemi commented Jun 5, 2020

When I load https://docs.rubocop.org/en/latest/versioning/ I get a 404 - "Page Not Found".

not sure if this is the right place to note that issue or not. apologies if it is not.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 5, 2020

@jmbuscemi We recently migrated the docs to a different system and this changed the URLs. Now it's https://docs.rubocop.org/rubocop/0.85/versioning.html

@jmbuscemi
Copy link

@bbatsov Thank you very much! I'm on 0.84 so that probably explains why the link is using the old URL.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 5, 2020

Yeah, exactly. We did the transition to the new system together with the release of 0.85.

@bbatsov bbatsov closed this as completed Jul 6, 2020
@cristianriano
Copy link

Also maybe useful for other people: You can use the flag ----disable-pending-cops or --enable-pending-cops when running Rubocop

Source:
https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml#L105

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 19, 2020

That's also in the docs for pending cops, btw - https://docs.rubocop.org/rubocop/versioning.html#enablingdisabling-pending-cops-in-bulk

@ciroque
Copy link

ciroque commented Nov 24, 2020

The problem I am having with this is that I use warnings as errors, this fails my builds and source control hooks, could it be an INFO not a WARNING?

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

No branches or pull requests