forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiplyDefined.qhelp
More file actions
29 lines (22 loc) · 834 Bytes
/
MultiplyDefined.qhelp
File metadata and controls
29 lines (22 loc) · 834 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
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p> Multiple assignments to a single variable without an intervening usage makes the first assignment redundant.
Its value is lost.
</p>
</overview>
<recommendation>
<p>Ensure that the second assignment is in fact correct.
Then delete the first assignment (taking care not to delete right hand side if it has side effects).</p>
</recommendation>
<example>
<p>In this example, <code>x</code> is assigned the value of 42 but then the value is changed to 12
before <code>x</code> is used. This makes the first assignment useless.</p>
<sample src="MultiplyDefined.py" />
</example>
<references>
<li>Python: <a href="http://docs.python.org/reference/simple_stmts.html#assignment-statements">Assignment statements</a>.</li>
</references>
</qhelp>