File tree Expand file tree Collapse file tree
javascript/ql/src/Declarations Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE qhelp PUBLIC
2+ "-//Semmle//qhelp//EN"
3+ "qhelp.dtd">
4+ <qhelp >
5+ <overview >
6+ <p >
7+ A value is assigned to a location, but either that location is never read
8+ later on, or its value is always overwritten before being read. This means
9+ that the original assignment has no effect, and could indicate a logic error or
10+ incomplete code.
11+ </p >
12+
13+ </overview >
14+ <recommendation >
15+
16+ <p >
17+ Ensure that you check the control and data flow in the method carefully.
18+ If a value is really not needed, consider omitting the assignment. Be careful,
19+ though: if the right-hand side has a side-effect (like performing a method call),
20+ it is important to keep this to preserve the overall behavior.
21+ </p >
22+
23+ </recommendation >
24+ <example >
25+
26+ <p >
27+ In the following example, the return value of the call to <code >send</code > on line 2
28+ is assigned to the local variable <code >result</code >, but then never used.
29+ </p >
30+
31+ <sample src =" examples/DeadStoreOfLocal.js" />
32+
33+ <p >
34+ Assuming that <code >send</code > returns a status code indicating whether the operation
35+ succeeded or not, the value of <code >result</code > should be checked, perhaps like this:
36+ </p >
37+
38+ <sample src =" examples/DeadStoreOfLocalGood.js" />
39+
40+ </example >
41+ <references >
42+
43+
44+ <li >Wikipedia: <a href =" http://en.wikipedia.org/wiki/Dead_store" >Dead store</a >.</li >
45+
46+
47+
48+ </references >
49+ </qhelp >
Original file line number Diff line number Diff line change 11<!DOCTYPE qhelp PUBLIC
2- "-//Semmle//qhelp//EN"
3- "qhelp.dtd">
4- <qhelp >
5- <overview >
6- <p >
7- A value is assigned to a local variable, but either that variable is never read
8- later on, or its value is always overwritten before being read. This means
9- that the original assignment has no effect, and could indicate a logic error or
10- incomplete code.
11- </p >
12-
13- </overview >
14- <recommendation >
15-
16- <p >
17- Ensure that you check the control and data flow in the method carefully.
18- If a value is really not needed, consider omitting the assignment. Be careful,
19- though: if the right-hand side has a side-effect (like performing a method call),
20- it is important to keep this to preserve the overall behavior.
21- </p >
22-
23- </recommendation >
24- <example >
25-
26- <p >
27- In the following example, the return value of the call to <code >send</code > on line 2
28- is assigned to the local variable <code >result</code >, but then never used.
29- </p >
30-
31- <sample src =" examples/DeadStoreOfLocal.js" />
32-
33- <p >
34- Assuming that <code >send</code > returns a status code indicating whether the operation
35- succeeded or not, the value of <code >result</code > should be checked, perhaps like this:
36- </p >
37-
38- <sample src =" examples/DeadStoreOfLocalGood.js" />
39-
40- </example >
41- <references >
42-
43-
44- <li >Wikipedia: <a href =" http://en.wikipedia.org/wiki/Dead_store" >Dead store</a >.</li >
2+ "-//Semmle//qhelp//EN"
3+ "qhelp.dtd">
454
5+ <qhelp >
466
7+ <include src =" DeadStore.qhelp" />
478
48- </references >
499</qhelp >
You can’t perform that action at this time.
0 commit comments