-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathUnnecessaryImport.qhelp
More file actions
35 lines (27 loc) · 1.28 KB
/
UnnecessaryImport.qhelp
File metadata and controls
35 lines (27 loc) · 1.28 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
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>An <code>import</code> statement that is not necessary (because no part
of the file that it is in uses any imported type) should be avoided. Although
importing too many types does not affect performance, redundant <code>import</code> statements
introduce unnecessary and undesirable dependencies in the code. If an imported type is
renamed or deleted, the source code cannot be compiled because the
<code>import</code> statement cannot be resolved.</p>
<p>Unnecessary <code>import</code> statements are often an indication of incomplete refactoring.</p>
</overview>
<recommendation>
<p>Avoid including an <code>import</code> statement that is not needed. Many modern IDEs have
automated support for doing this, typically under the
name 'Organize imports'. This sorts the <code>import</code> statements and
removes any that are not used, and it is good practice to run such a
command before every commit.</p>
</recommendation>
<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>