title: What is Cognitive Complexity in sonar report?
body: <p>Now a days i switched to sonar reports for static code review and performance improvement. Under the rules section I found that the cognitive complexity of my methods are high.</p>
  
  <p>You can find cognitive complexity error in sonar as:
  Go to <strong>Project->Issues Tab->Rules Drop-down->Cognitive Complexity</strong></p>
  
  <p>Below screen shot gives you a reference of sonar project:</p>
  
  <p><a href="https://i.stack.imgur.com/cwcGH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cwcGH.png" alt="enter image description here"></a></p>
  
  <p>I was not getting any way to calculate and reduce the cognitive complexity of my methods. Finally I found the accurate way to calculate the complexity and i will answer this in my post below. Please check out.</p>