为什么我的本地项目中有很多罪行,而我的队友没有任何罪行?

发布于 2025-01-27 18:26:50 字数 376 浏览 3 评论 0 原文

我们在项目中使用RuboCop,问题是当我使用Rubocop时,我会遇到182次进攻,而同一分支中的队友也没有得到任何攻击,我们拥有相同的Ruby,Rails和Rubocop版本。

spec/rails_helper.rb:45:4: C: [Correctable] Style/FetchEnvVar: Use ENV.fetch("RAILS_ENV") or ENV.fetch("RAILS_ENV", nil) instead of ENV["RAILS_ENV"].
if ENV["RAILS_ENV"] == "test"

我遇到的犯罪的一个例子。

Rubocop V:1.28.2 Rails V:6.0.3.4 Ruby V:2.7.2

We are using rubocop in our project, the problem is when I use rubocop I get 182 offenses while my team mates in the same branch don't get any, we have the same ruby, rails and rubocop version.

spec/rails_helper.rb:45:4: C: [Correctable] Style/FetchEnvVar: Use ENV.fetch("RAILS_ENV") or ENV.fetch("RAILS_ENV", nil) instead of ENV["RAILS_ENV"].
if ENV["RAILS_ENV"] == "test"

One example of the offenses that I got.

Rubocop v: 1.28.2
rails v: 6.0.3.4
ruby v: 2.7.2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

生来就爱笑 2025-02-03 18:26:50

.rubocop_todo.yml 文件过滤掉列表rubocop罪行。
如果您的队友有一个,而您没有,或者您有此文件的不同版本,则Rubocop将标记不同的罪行。

.rubocop_todo.yml files filter out a list Rubocop offenses.
If your teammates have one and you do not, or if you have a different version of this file, then different offenses will be flagged by Rubocop.

https://docs.rubocop.org/rubocop/configuration.html#automatically-generated-configuration

肩上的翅膀 2025-02-03 18:26:50

影响RuboCop的因素只有两个因素:Rubocop Gem版本和.rubocop.yml配置。

您可以运行 rubocop -debug 以查看有关配置的更多详细信息。

There are only two factors influencing rubocop: rubocop gem version and .rubocop.yml configuration.

You can run rubocop --debug to see more details about configuration which is used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文