Skip to content

Commit 06f4374

Browse files
author
Max Schaefer
committed
JavaScript: Generalize description of js/unused-local-variable.
The query also flags unused imports, functions and classes (which, of course, are just unused variables at the end of the day). This is now made more explicit in the description.
1 parent d91218e commit 06f4374

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

change-notes/1.18/analysis-javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
| Server-side URL redirect | More true-positive results | This rule now treats header names case-insensitively. |
4646
| Uncontrolled command line | More true-positive results | This rule now recognizes indirect command injection through `sh -c` and similar. |
4747
| Unused variable | Fewer results | This rule no longer flags class expressions that could be made anonymous. While technically true, these results are not interesting. |
48+
| Unused variable | Renamed | This rule has been renamed to "Unused variable, import, function or class" to reflect the fact that it flags different kinds of unused program elements. |
4849

4950
## Changes to QL libraries
5051

javascript/ql/src/Declarations/UnusedVariable.qhelp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77
Unused local variables make code hard to read and understand. Any computation used to initialize
88
an unused variable is wasted, which may lead to performance problems.
99
</p>
10+
<p>
11+
Similarly, unused imports and unused functions or classes can be confusing. They may even be
12+
a symptom of a bug caused, for example, by an incomplete refactoring.
13+
</p>
1014

1115
</overview>
1216
<recommendation>
1317

14-
<p>Remove the unused variable.</p>
18+
<p>Remove the unused program element.</p>
1519

1620
</recommendation>
1721
<example>

javascript/ql/src/Declarations/UnusedVariable.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
2-
* @name Unused variable
3-
* @description Unused variables may be a symptom of a bug and should be examined carefully.
2+
* @name Unused variable, import, function or class
3+
* @description Unused variables, imports, functions or classes may be a symptom of a bug
4+
* and should be examined carefully.
45
* @kind problem
56
* @problem.severity recommendation
67
* @id js/unused-local-variable

0 commit comments

Comments
 (0)