<!DOCTYPE qhelp PUBLIC
  "-//Semmle//qhelp//EN"
  "qhelp.dtd">
<qhelp>

<overview>
<p>The result of certain comparison tests can sometimes be inferred from their
context and the results of other
comparisons.  This can be an indication of faulty logic and may result in dead
code or infinite loops if, for example, a loop condition never changes its value.
</p>

</overview>
<recommendation>
<p>Inspect the code to check whether the logic is correct, and consider
simplifying the logical expression.
</p>

</recommendation>
<example>
<p>In the following example the final test on <code>x</code> will always be
<code>true</code>, and thus the condition is redundant and potentially wrong.
If the "do more stuff" part is intended to always execute after the loop then
the condition should be removed to make this clear.
</p>

<sample src="UselessComparisonTest.java" />

</example>
<references>

<li>
Java Language Specification:
<a href="http://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.9">The if Statement</a>.
</li>

</references>
</qhelp>
