title: How to avoid useless else block statements to increase branch coverage in unit test cases?
body: <p>Considering the following code:</p>
  
  <pre><code>    function test(val){
          flag = val;        
  
          if (!flag) {
              doThis();
          }     
          createSomething();
     }
  </code></pre>
  
  <p>So, considering the unit test coverage, even the function statement is covered, the branches are not covered as else block doesn't exist. So the branches covered will be 50% and due to sonar issues, we will not be able to merge this to develop. So to get rid off this, useless code we write like <code>return false;</code> in the else block and make the script grow. </p>
  
  <p>Is it efficient way of writing the code? Is there a way to avoid writing useless un-necessary codes just to make sure the coverage is 100%. This is a bad practise, need suggestions to get rid off this. Do we have any setting, so that we can update ignore <code>else</code> block statements and increase the coverage if not defined.</p>
  
  <p>Sonar forces to write else block:</p>
  
  <p><a href="https://i.stack.imgur.com/qOSWU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qOSWU.png" alt="enter image description here"></a></p>
  
  <p>I have 100% code coverage, but the branch coverage is 50% just because of ignoring the else block. There are sonar rules defined if not more than 80%, we could not merge the code :(</p>