Files
codeql/javascript/ql/src/Statements/UselessRangeCheck.qhelp
2018-11-29 11:22:14 +00:00

48 lines
1.1 KiB
XML

<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
If a condition always evaluates to true or always evaluates to false, this often indicates
incomplete code or a latent bug and should be examined carefully.
</p>
</overview>
<recommendation>
<p>
Examine the surrounding code to determine why the condition is useless. If it is no
longer needed, remove it.
</p>
<p>
If the check is needed to guard against NaN values, insert a comment explaning the possibility of NaN.
</p>
</recommendation>
<example>
<p>
The following example finds the index of an element in a given slice of the array:
</p>
<sample src="examples/UselessConditional.js" />
<p>
The condition <tt>i &lt; end</tt> at the end is always false, however. The code can be clarified if the
redundant condition is removed:
</p>
<sample src="examples/UselessConditionalGood.js" />
</example>
<references>
<li>Mozilla Developer Network: <a href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy">Truthy</a>,
<a href="https://developer.mozilla.org/en-US/docs/Glossary/Falsy">Falsy</a>.</li>
</references>
</qhelp>