forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUselessComparisonTest.qhelp
More file actions
35 lines (25 loc) · 983 Bytes
/
UselessComparisonTest.qhelp
File metadata and controls
35 lines (25 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>The result of certain comparisons 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 (real world) example the test <code>obj1 < obj2</code> is repeated and thus the
second test will always be false, and the function <code>_compare</code> will only ever return <code>0</code> or <code>-1</code>.
</p>
<sample src="UselessComparisonTest.py" />
</example>
<references>
<li>Python Language Reference: <a href="http://docs.python.org/2/reference/expressions.html#not-in">Comparisons</a>.</li>
</references>
</qhelp>