VSCode/Rubocop 抱怨未配置的警察
VSCode/Rubocop complaining about unconfigured cops
我最近更新了 rubocop
我正在处理的 gem。当我使用 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/
警告指示我单独启用这些新警察中的每一个,但文档似乎有一个更简单的解决方案,但不起作用。我在这里做错了什么?
我这里也有同样的问题。 AllCops
中的 NewCops
参数无法识别,因此只有一种方法可以做到这一点,即单独禁用或启用每个警察,如下所示:
Lint/RaiseException:
Enabled: false
Lint/StructNewOverride:
Enabled: false
Style/HashEachMethods:
Enabled: false
Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: false
希望这对您有所帮助。
尚不支持 NewCops
参数。但是,它将在 Rubocop 的下一个版本中得到支持。在此参数旁边,您还可以使用 --enable-pending-cops
和 --disable-pending-cops
命令行选项。
目前 EL Zakariae 的解决方案是消除此警告的唯一方法。
您可以找到相应的拉取请求here。
如果您使用的是 VS 代码 ruby-rubocop 版本,这里有一个简单的修复程序 ->
配置扩展设置 -> Select 抑制 Rubocop 警告,如果您在存储库中共享 rubocop.yml 文件会很有帮助。
我最近更新了 rubocop
我正在处理的 gem。当我使用 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/
警告指示我单独启用这些新警察中的每一个,但文档似乎有一个更简单的解决方案,但不起作用。我在这里做错了什么?
我这里也有同样的问题。 AllCops
中的 NewCops
参数无法识别,因此只有一种方法可以做到这一点,即单独禁用或启用每个警察,如下所示:
Lint/RaiseException:
Enabled: false
Lint/StructNewOverride:
Enabled: false
Style/HashEachMethods:
Enabled: false
Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: false
希望这对您有所帮助。
尚不支持 NewCops
参数。但是,它将在 Rubocop 的下一个版本中得到支持。在此参数旁边,您还可以使用 --enable-pending-cops
和 --disable-pending-cops
命令行选项。
目前 EL Zakariae 的解决方案是消除此警告的唯一方法。
您可以找到相应的拉取请求here。
如果您使用的是 VS 代码 ruby-rubocop 版本,这里有一个简单的修复程序 ->
配置扩展设置 -> Select 抑制 Rubocop 警告,如果您在存储库中共享 rubocop.yml 文件会很有帮助。