Skip to content

Commit 758e74a

Browse files
authored
Merge pull request #455 from felicity-semmle/java/SD-2779-qhelp-updates
Java: Update qhelp for queries with CWE tags (SD-2779)
2 parents a499009 + fe15159 commit 758e74a

File tree

8 files changed

+19
-25
lines changed

8 files changed

+19
-25
lines changed

java/ql/src/Violations of Best Practice/Dead Code/DeadStoreOfLocalUnread.qhelp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66

77
<overview>
8-
<p>A value is assigned to a local variable, but the variable is never read subsequently. This means
9-
that the original assignment is suspect, because the state of the local variable that
8+
<p>A value is assigned to a local variable, but the local variable is only
9+
read before the assignment, not after it.
10+
This means that the assignment is suspect, because the state of the local variable that
1011
it creates is never used.</p>
1112

1213
</overview>
@@ -17,4 +18,6 @@ though: if the right-hand side has a side-effect (like performing a method call)
1718
it is important to keep this to preserve the overall behavior.</p>
1819

1920
</recommendation>
21+
22+
<include src="../../DeadCode/DeadCodeReferences.qhelp" />
2023
</qhelp>

java/ql/src/Violations of Best Practice/Dead Code/DeadStoreOfLocalUnread.ql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/**
22
* @name Useless assignment to local variable
3-
* @description A value is assigned to a local variable, but the local variable
4-
* is only read before the assignment, not after it.
5-
* The assignment has no effect: either it should be removed,
6-
* or the assigned value should be used.
3+
* @description Assigning a value to a local variable that is not later used has no effect.
74
* @kind problem
85
* @problem.severity recommendation
96
* @precision low

java/ql/src/Violations of Best Practice/Dead Code/LocalInitialisedButNotUsed.qhelp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<overview>
88
<p>A local variable is initialized, but the variable is never read or written to subsequently. This suggests
9-
that the local variable is either useless and should be removed, or that the value was intended to be used
9+
that the local variable is either unnecessary and should be removed, or that the value was intended to be used
1010
somewhere.
1111
</p>
1212

@@ -18,4 +18,7 @@ though: if the right-hand side has a side-effect (like performing a method call)
1818
it is important to keep this to preserve the overall behavior.</p>
1919

2020
</recommendation>
21+
22+
<include src="../../DeadCode/DeadCodeReferences.qhelp" />
23+
2124
</qhelp>

java/ql/src/Violations of Best Practice/Dead Code/LocalInitialisedButNotUsed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Local variable is initialized but not used
3-
* @description A local variable is initialized once, but never read or written to. Either the local variable is useless, or its value was intended to be used but is not.
3+
* @description A local variable that is initialized but not subsequently used may indicate an error in the code.
44
* @kind problem
55
* @problem.severity recommendation
66
* @precision low

java/ql/src/Violations of Best Practice/Dead Code/UnusedLocal.qhelp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,17 @@
55

66

77
<overview>
8-
<p>A local variable that is never accessed nor initialized
9-
is typically a leftover from old refactorings or a sign of incomplete or pending
10-
code changes.</p>
8+
<p>A local variable that is not accessed or initialized
9+
is typically a sign of incomplete or pending code changes.</p>
1110

1211
</overview>
1312
<recommendation>
1413

15-
<p>If an unused variable is a leftover from old refactorings, you should just remove it. If it indicates
16-
incomplete or pending code changes, finish making the changes and remove the variable if it is not
14+
<p>If an unused variable is no longer needed following refactoring, you should just remove it. If there are
15+
incomplete or pending code changes, finish making the changes, and then remove the variable if it is no longer
1716
needed.</p>
1817

1918
</recommendation>
20-
<references>
2119

22-
23-
<li>
24-
Help - Eclipse Platform:
25-
<a href="http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fpreferences%2Fjava%2Fcompiler%2Fref-preferences-errors-warnings.htm">Java Compiler Errors/Warnings Preferences</a>.
26-
</li>
27-
28-
29-
</references>
20+
<include src="../../DeadCode/DeadCodeReferences.qhelp" />
3021
</qhelp>

java/ql/src/Violations of Best Practice/Dead Code/UnusedLocal.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Unused local variable
3-
* @description A local variable is entirely unused: it is not initialized, written to or read. The variable serves no purpose and obscures the code. It should be removed.
3+
* @description A local variable that is not initialized, assigned, or read may indicate incomplete code.
44
* @kind problem
55
* @problem.severity recommendation
66
* @precision low

java/ql/src/Violations of Best Practice/legacy/InexactVarArg.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ private static void length(Object... objects) {
77
public static void main(String[] args) {
88
String[] words = { "apple", "banana", "cherry" };
99
String[][] lists = { words, words };
10-
length(words); // BAD: Argument does not clarify
10+
length(words); // avoid: Argument does not clarify
1111
length(lists); // which parameter type is used.
1212
}
1313
}

java/ql/src/Violations of Best Practice/legacy/InexactVarArg.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ versions of Eclipse, the output may be:</p>
4949

5050
<sample src="InexactVarArg.java" />
5151

52-
<p>To fix the code, <code>length(words)</code> should be replaced by either of the following:</p>
52+
<p>To avoid this compiler-dependent behavior, <code>length(words)</code> should be replaced by either of the following:</p>
5353

5454
<ul>
5555
<li><code>length((Object) words)</code></li>

0 commit comments

Comments
 (0)