我们正在将 CodeClimate 添加到一个项目中,并且在我们的 React 组件中method-lines
的函数中遇到了很多错误,render
例子:-
函数
render
有 78 行代码(允许超过 40 行)。考虑重构。
我们想从检查中过滤掉我们所有的render
功能。method-lines
我们可以提高线路阈值或完全禁用检查,但我们仍然希望检查其他功能,所以这是不可取的。
有用于重复检查的节点过滤,但我找不到任何类似的method-lines
.
我们正在将 CodeClimate 添加到一个项目中,并且在我们的 React 组件中method-lines
的函数中遇到了很多错误,render
例子:-
函数
render
有 78 行代码(允许超过 40 行)。考虑重构。
我们想从检查中过滤掉我们所有的render
功能。method-lines
我们可以提高线路阈值或完全禁用检查,但我们仍然希望检查其他功能,所以这是不可取的。
有用于重复检查的节点过滤,但我找不到任何类似的method-lines
.
您需要一个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 需要准确的缩进。祝你好运!