【问题标题】:Filtering render functions from CodeClimate method-lines check从 CodeClimate 方法行检查中过滤渲染函数
【发布时间】:2018-12-10 19:35:54
【问题描述】:

我们正在将 CodeClimate 添加到一个项目中,并且在我们的 React 组件中的 render 函数中遇到了很多 method-lines 错误,

例子:-

函数 render 有 78 行代码(允许超过 40 行)。考虑重构。

我们想从method-lines 检查中过滤掉我们所有的render 函数。我们可以提高行阈值或完全禁用检查,但我们仍然希望检查其他功能,所以这是不可取的。

node filtering 用于重复检查,但我找不到method-lines 的类似内容。

【问题讨论】:

标签: reactjs code-climate


【解决方案1】:

您需要一个 codwclimate.yml 文件,并且可以使用以下内容更改阈值 - 尽管拥有巨大的渲染功能并不是很好 - 我建议也将其保持在 50 行以下。

version: "2"         # required to adjust maintainability checks
checks:
 argument-count:
   config:
     threshold: 4
   complex-logic:
    config:
     threshold: 4
   file-lines:
    config:
     threshold: 250
   method-complexity:
    config:
     threshold: 5
   method-count:
    config:
     threshold: 20
   method-lines:
    config:
     threshold: 25

这是来自这里的文档:https://docs.codeclimate.com/docs/advanced-configuration#section-default-check-configurations

method-lines 是上面的最后一个 - 请确保不要剪切/粘贴,因为 YML 需要准确的缩进。祝你好运!

【讨论】:

  • 此配置如何仅影响渲染功能?还是会影响所有功能?
猜你喜欢
  • 2018-02-13
  • 2021-07-12
  • 2019-01-17
  • 2019-08-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多