Answer a question

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?

Answers

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.

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐