mgechev / mgechev/codelyzer

template-conditional-complexity not reporting failures in some cases

Open
#627 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2.5k
Forks
232
PR merge metrics
No merged PRs in 30d

Description

**Config:**
```JSON
{
"rules": {
"template-conditional-complexity": [
true,
2
]
}
}
```

**1st. case:** (when the *ngIf contains a `pipe` it doesn't work well)

```ts
@Component({
template: `

Content

`
})
class Test {}
```

**2nd. case:** (boolean checks not being computed the same way as `===` or `!==`):

```ts
@Component({
template: `




`
})
class Test {}
```


**PS:**
I'm not sure if it's a bad thing or not for everyone, but once I started using this rule, always I have to choose which rule should be disabled: this (`template-conditional-complexity`) or `no-template-call-expression`, because once you move your big (or even small) conditional to component, as the failure claims you to do, `no-template-call-expression` will report a failure, so you have to disable one of them.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the shown template-conditional-complexity configuration with both Angular template examples, comparing the pipe case with the boolean checks. Trace how the rule evaluates these template expressions; done means both cases report the intended complexity failures and the behavior is covered by regression tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.