Rob*_*ert 12 reactjs code-climate
我们将CodeClimate添加到项目中,并在React组件中method-lines的render功能中遇到很多错误,例如
函数
render有78行代码(允许超过40行)。考虑重构。
我们想render从method-lines检查中过滤掉所有功能。我们可以增加线路阈值或完全禁用检查,但是我们仍然希望检查其他功能,所以这是不可取的。
有用于重复检查的节点过滤,但是我找不到类似的东西method-lines。
jsw*_*324 -3
你需要一个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
Run Code Online (Sandbox Code Playgroud)
这是来自此处的文档:https://docs.codeclimate.com/docs/advanced-configuration#section-default-check-configurations
method-lines是上面的最后一个 - 请确保不要剪切/粘贴,因为 YML 需要精确的缩进。祝你好运!
| 归档时间: |
|
| 查看次数: |
201 次 |
| 最近记录: |