title: SonarQube - boolean logic correctness -
body: <p>I have a problem with the logic expression on my method <strong>matches1()</strong>.</p>
  
  <h2>Problem</h2>
  
  <p>SonarQube is telling me there is an error:
  <code>(expectedGlobalRule == null &amp;&amp; actual != null)</code></p>
  
  <blockquote>
    <p><strong>SonarQube:</strong>
    Change this condition so that it does not always evaluate to
    "true".
        Conditions should not unconditionally evaluate to "TRUE" or to "FALSE"</p>
  </blockquote>
  
  <p>I'm essentially doing this logic to avoid a <em>NPE</em> on my "Block to be executed".</p>
  
  <h2>My code</h2>
  
  <p><strong>matches1()</strong></p>
  
  <pre><code>private boolean matches1(GbRule actual, GbRule expected) {
       if(actual == null &amp;&amp; expected == null) {
          return true;
       } else if((expected == null &amp;&amp; actual != null) || (expected != null &amp;&amp; actual == null)) {
          return false;
       } else {
         //Block to be executed
       }
  }
  </code></pre>
  
  <p>I inverted the logic in to see what SonarQube would tell me and he doesn't complain about it.
  <strong>matches2()</strong>       </p>
  
  <pre><code>private boolean matches2(GbRule actual, GbRule expected) {
        if(actual == null &amp;&amp; expected == null) {
           return true;
        } else if(expected != null &amp;&amp; actual != null)  {
           //Block to be executed
        } else {
           return false;
        }
  }
  </code></pre>
  
  <h2>Question</h2>
  
  <ol>
  <li>Do the problem is in my boolean logic or it's SonarQube that lost
  his mind?</li>
  <li>If the problem is within sonarQube, how could I resolve it?</li>
  </ol>