angular - tslint 吐出圈复杂度错误
问题描述
在我的 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]”中设置的内容与我为许多文件“(成本'5')”收到的错误消息之间存在这种差异?
另外,为什么会发生这种情况?
解决方案
模板复杂度在不同的规则内,即:
"template-cyclomatic-complexity": [true, 6]
来源https://github.com/fulls1z3/angular-tslint-rules/issues/34
"cyclomatic-complexity": [true, 20],
适用于 *.ts 文件
推荐阅读
- typescript - TypeScript 中的通用类型链表?
- python - 多边形内的python点(点云数据)
- mysql - Mysql Query不更新特定记录
- python - 硒python的get_attribute问题
- java - 如何为 Hibernate 验证做一个正则表达式模式?
- r - 如何将自定义函数应用于嵌套数据框?
- php - 使用 XAMPP 在 Windows 10 中安装 go-pear.phar 时出错
- vue.js - 如何在 Nuxt JS 中将变量值从“页面”传递到“布局”?
- java - 尝试在 QT 项目中调用 Java 代码时找不到类异常
- apache-kafka-streams - 使用 Kafka Streams 分配多个主题的消费者