React hook nested functions Complexity overflow

Sonar version: 9.2.4 (build 50792)


We use react-hook in our project and

We try to rewiew our code and fix sonar issues on our project but we have some errors about complexity like below:


We expect that when in nested function it start count from 1 but it continue to count.

Is there any options about that or how can we fix it ?

Hello Huseyin,

Welcome to the Community and thank you for brining this up!

I agree with you, function definitions shouldn’t increase the Cognitive Complexity of their parents.
Although there might be some cognitive overhead if the child function uses parent’s variables (closure).

We have fixed some aspects of this in the past for React, like ticket #2238.
But we need to do more, like in the case you bring up.

We have a ticket that partially covers this #3289, which you can follow to get updates.


1 Like