本文介绍了如何告诉Rubocop忽略特定的目录或文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目是将开源类从我们不想保留的第三方gem扩展到与我们自己的代码相同的编码标准.重构gem代码不是一个可行的选择.我们只希望Rubocop忽略复制的代码.

My project is extending open-source classes from a third-party gem that we don't want to hold to the same coding standards as our own code. Refactoring the gem code isn't a viable option. We just want Rubocop to ignore the copied code.

如何指示Rubocop完全忽略文件或目录?

How can I instruct Rubocop to completely ignore a file or directory?

推荐答案

根据Orde的评论以及指向我找到了.rubocop.yml并添加了以下内容:

As per orde's comment with the link to the manual I found .rubocop.yml and added the following:

AllCops:
  Exclude:
    - 'path/to/excluded/file.rb'

相对于.rubocop.yml的路径

where the path is relative to .rubocop.yml

这篇关于如何告诉Rubocop忽略特定的目录或文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-30 07:27