Search code examples
angulartslint

tslint spitting out cyclomatic complexity error


On my angular 8 project with

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

After running :

ng lint myapp --fix=true

I get :

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

even though in my tslint.js I set :

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

Why is there this discrepancy between what I set in the settings ""cyclomatic-complexity": [true, 20]" and this error message I'm getting for many many files "(cost '5')"?

Also why is this happening at all?


Solution

  • The template complexity is inside a different rule, namely:

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

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

    "cyclomatic-complexity": [true, 20], is for *.ts files