title: How does Sonar calculate the cyclomatic complexity?
body: <p>Sonar gives me the following cyclomatic complexity number : 22.</p>
  <p>For the following program :</p>
  <pre><code>private static SomeDto checkSomething(AnotherDto anotherDto, String reference)
  {
  SomeDto someDto = new SomeDto();
  
  // condition 1
  if (!someDto.getA())
      return new SomeDto(&quot;bla1&quot;, &quot;blabla&quot;);
  
  // condition 2
  if (someDto.getName2() == null || checkSurName(anotherDto.getName()))
      return new SomeDto(&quot;bla2&quot;, &quot;blabla&quot;);
  
  // condition 3
  if (someDto.getName3() == null || checkSurName(anotherDto.getName()))
      return new SomeDto(&quot;bla3&quot;, &quot;blabla&quot;);
  
  // condition 4
  if (someDto.getName4() == null &amp;&amp; checkSurName(anotherDto.getName()))
      return new SomeDto(&quot;bla4&quot;, &quot;blabla&quot;);
  
  // condition 5
  if (someDto.getName5() == null || checkSurName(anotherDto.getName()))
      return new SomeDto(&quot;bla5&quot;, &quot;blabla&quot;);
  
  // condition 6
  if (someDto.getName6() == null &amp;&amp; checkSurName(anotherDto.getName()))
      return new SomeDto(&quot;bla6&quot;, &quot;blabla&quot;);
  
  // condition 7
  if (someDto.getName7() == null &amp;&amp; checkSurName(anotherDto.getName()))
      return new SomeDto(&quot;bla7&quot;, &quot;blabla&quot;);
  
  // condition 8
  if (someDto.getName8() == null &amp;&amp; checkSurName(anotherDto.getName()))
      return new SomeDto(&quot;bla8&quot;, &quot;blabla&quot;);
  
  // condition 9
  if (someDto.getName9() == null &amp;&amp; checkSurName(anotherDto.getName()))
      return new SomeDto(&quot;bla9&quot;, &quot;blabla&quot;);
  
  // condition 10
  if (someDto.getName10() == null &amp;&amp; checkSurName(anotherDto.getName()))
      return new SomeDto(&quot;bla10&quot;, &quot;blabla&quot;);
  
  // condition 11
  if (someDto.getName11() == null &amp;&amp; checkSurName(anotherDto.getName()))
      return new SomeDto(&quot;bla11&quot;, &quot;blabla&quot;);
  
  return someDto;
  }    
  </code></pre>
  <p>The issue i get is the following :</p>
  <p><em>&quot;The Cyclomatic Complexity of this method &quot;checkSomething&quot; is 22 which is greater than 12 authorized.</em>&quot;</p>
  <p>My question is :
  considering the McCabe formula V(G) = E - N + 2, how does Sonar reach the number of 22 ?</p>
  <p>Where :</p>
  <p>E = number of edges</p>
  <p>N = number of nodes</p>
  <p>How many edges and nodes are there in this method  ?
  What is the control flow for this method ?</p>
  <p>We're on SonarQube Version 6.3 (build 19869).</p>