【问题标题】:tslint spitting out cyclomatic complexity errortslint 吐出圈复杂度错误
【发布时间】:2019-09-09 23:56:16
【问题描述】:

在我的 Angular 8 项目中使用

"codelyzer": "^5.1.0",
"ts-node": "~8.3.0",
"tslint": "~5.19.0",

运行后:

ng lint myapp --fix=true

我明白了:

ERROR: ...html:428:106 - The cyclomatic complexity exceeded the defined limit (cost '5'). Your template should be refactored.

即使在我的tslint.js 我设置了:

{
  "rulesDirectory": ["node_modules/codelyzer"],
  "rules": {
    "template-i18n": false,
    "cyclomatic-complexity": [true, 20],

为什么我在设置 ""cyclomatic-complexity": [true, 20]" 中设置的内容与我为许多文件 "(cost '5')" 收到的错误消息之间存在这种差异?

还有为什么会发生这种情况?

【问题讨论】:

    标签: angular tslint


    【解决方案1】:

    模板复杂度在不同的规则内,即:

    "template-cyclomatic-complexity": [true, 6]
    

    来源https://github.com/fulls1z3/angular-tslint-rules/issues/34

    "cyclomatic-complexity": [true, 20], 用于 *.ts 文件

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-29
      • 2020-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多