Cognitive complexity wrong behavior on python code?

Hi all, I have this question that I searched no one raised, is it correct that the Cognitive Complexity doesn’t take in consideration nested function definition?
I’m using:
* Windows 10
* Sonarlint v3.19.0
* Python
* Not Connected to SonarCloud or SonarQube

As you can see in the attached image, Sonarlint start count the location for Cognitive complexity point even if they are in nested function definition so the body of the main function starts with a high value and not 1.
thanks for any reply

Hello @lkolfy,

First, sorry for the late answer.
As you can see in the white paper linked on this page, cognitive complexity does take into account nested function definition, except for decorators.

To qualify for the decorator exception, a function may contain only a nested function and a return
statement. Note that the exception only removes the nesting penalty, though.

In your case, there are multiple nested functions, so the exception does not apply.

Hope that helps,