Wrong detection of Cognitive Complexity

For code snippet, please refer screenshot. In this ‘If’ condition is not nested.
SonarQube version - 9.1.0
Scanner version - 4.6.2
language analyzer - Swift

Hello @shubham.singh,

Welcome to SonarSource community, and thank you for your message!

In order to help you, I would need you to clarify what is exactly the problem. With the screenshot you provided, I am not sure what I should look at, and I am also unable to further investigate any miscalculation of the cognitive complexity of your function. Therefore, I invite you to provide me with a minimal, reproducible example.

Best regards,
Yassin