JavaScript

JavaScript

Made by DeepSource

Cyclomatic complexity is more than allowed for the template JS-0590

Performance
Minor
angular

Cyclomatic complexity is a quantitative measure of the number of linearly independent paths through a program’s source code. Cyclomatic complexity over some threshold indicates that the logic should be moved outside the template.

The default complexity threshold is 5. The threshold can be changed in your ESLint configuration by setting the maxComplexity option for @angular-eslint/template/cyclomatic-complexity rule.

Bad Practice

<div *ngIf="a === '1'">
    <div *ngFor="let person of persons; trackBy: trackByFn">
    <div *ngIf="a === '1'">{{ person.name }}</div>
    <div [ngSwitch]="person.emotion">
        <app-happy-hero    *ngSwitchCase="'happy'"    [hero]="currentHero"></app-happy-hero>
        <app-sad-hero      *ngSwitchCase="'sad'"      [hero]="currentHero"></app-sad-hero>
        <app-confused-hero *ngSwitchCase="'confused'" [hero]="currentHero"></app-confused-hero>
        <app-unknown-hero  *ngSwitchDefault           [hero]="currentHero"></app-unknown-hero>
    </div>
    </div>
</div>

Recommended

<div *ngIf="a === '1'">
    <div>{{ person.name }}</div>
</div>