-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathUnreadLocal.qhelp
More file actions
42 lines (29 loc) · 1.33 KB
/
UnreadLocal.qhelp
File metadata and controls
42 lines (29 loc) · 1.33 KB
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
36
37
38
39
40
41
42
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>A local variable that is never read is useless.</p>
<p>As a matter of good practice, there should be no unused or useless code. It makes the program
more difficult to understand and maintain, and can waste a programmer's time.</p>
</overview>
<recommendation>
<p>This rule applies to variables that are never used as well as variables that are only
written to but never read. In both cases, ensure that no operations are missing that would use the
local variable. If appropriate, simply remove the declaration. However, if the variable is
written to, ensure that any side-effects in the assignments are retained. (For further
details, see the example.)</p>
</recommendation>
<example>
<p>In the following example, the local variable <code>oldQuantity</code> is assigned a value but
never read. In the fixed version of the example, the variable is removed but the call to
<code>items.put</code> in the assignment is retained.</p>
<sample src="UnreadLocal.java" />
</example>
<references>
<li>
Help - Eclipse Platform:
<a href="https://help.eclipse.org/2020-12/advanced/content.jsp?topic=/org.eclipse.jdt.doc.user/reference/preferences/java/compiler/ref-preferences-errors-warnings.htm">Java Compiler Errors/Warnings Preferences</a>.
</li>
</references>
</qhelp>