Cognitive-Complexity-TS
Cognitive-Complexity-TS copied to clipboard
Doesn't calculate logical operator sequences correctly
Take this example:
function stuff() {
if (val > someConstant && (condition2 || condition3) && condition4 && !condition5 || val < someOtherConstant) {
}
}
This is calculated as a complexity of 3
. You can add or remove as many conditions to this as you want and it will still only ever count as 3
.
The cognitive complexity spec this is based on specifies that the complexity grows with each mixed condition.
Similarly, negations should also increment this number as this increases cognitive load directly.