Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode/Rubocop complaining about unconfigured cops

I've recently updated rubocop for a gem I'm working on. When I open a ruby file in the project using VSCode, I get the following warning:

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)
For more information: https://docs.rubocop.org/en/latest/versioning/

Here is my .rubocop.yml file:

Metrics/MethodLength:
  Max: 20
Layout/LineLength:
  Max: 100
AllCops:
  Exclude:
    - 'spec/**/*'

When I visit the url in the warning it mentions adding a NewCops setting like so:

Metrics/MethodLength:
  Max: 20
Layout/LineLength:
  Max: 100
AllCops:
  NewCops: enable
  Exclude:
    - 'spec/**/*'

However, I'm getting this new warning:

Warning: AllCops does not support NewCops parameter.

Supported parameters are:

  - RubyInterpreters
  - Include
  - Exclude
  - DefaultFormatter
  - DisplayCopNames
  - DisplayStyleGuide
  - StyleGuideBaseURL
  - ExtraDetails
  - StyleGuideCopsOnly
  - EnabledByDefault
  - DisabledByDefault
  - UseCache
  - MaxFilesInCache
  - CacheRootDirectory
  - AllowSymlinksInCacheRootDirectory
  - TargetRubyVersion
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)
For more information: https://docs.rubocop.org/en/latest/versioning/

The warning instructs me to enable each of these new cops individually but the docs seem to have an easier solution that doesn't work. What am I doing wrong here?

like image 504
aarona Avatar asked Apr 08 '20 19:04

aarona


3 Answers

If you are using VS code ruby-rubocop version here is a simple fix for you ->

Configure extension settings -> Select Supress Rubocop Warnings , it is helpful if you share rubocop.yml file in the repository.

image

like image 137
spidyj Avatar answered Nov 08 '22 19:11

spidyj


I have the same issue here. The NewCops parameter inside AllCops is not recognized so there is only one way to do it which is by disabling or enabling each cop alone like so:

Lint/RaiseException:
  Enabled: false
Lint/StructNewOverride:
  Enabled: false
Style/HashEachMethods:
  Enabled: false
Style/HashTransformKeys:
  Enabled: false
Style/HashTransformValues:
  Enabled: false

Hope this was helpful.

like image 5
Zakariae El Mejdki Avatar answered Nov 08 '22 19:11

Zakariae El Mejdki


The NewCops parameter is not supported yet. However, it will be supported in the next release of Rubocop. Next to this parameter, you will also be able to use --enable-pending-cops and --disable-pending-cops command-line options.

For the moment EL Zakariae's solution is the only way to remove this warning.

You can find the corresponding pull request here.

like image 1
Simon Isler Avatar answered Nov 08 '22 20:11

Simon Isler