gpt4 book ai didi

ruby - VSCode/Rubocop 提示未配置的警察

转载 作者:行者123 更新时间:2023-12-03 18:13:56 29 4
gpt4 key购买 nike

我最近为我正在开发的 gem 更新了 rubocop。当我使用 VSCode 在项目中打开一个 ruby​​ 文件时,我收到以下警告:

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/

这是我的 .rubocop.yml 文件:

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

当我在警告中访问 url 时,它提到添加一个 NewCops 设置,如下所示:

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

但是,我收到了这个新警告:
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/

警告指示我单独启用这些新警察中的每一个,但文档似乎有一个更简单的解决方案,但不起作用。我在这里做错了什么?

最佳答案

我在这里也有同样的问题。 NewCops 中的 AllCops 参数无法识别,因此只有一种方法是通过单独禁用或启用每个警察,如下所示:

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

希望这是有帮助的。

关于ruby - VSCode/Rubocop 提示未配置的警察,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61108623/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com