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 @@ -123,6 +123,15 @@ class ImportVarDeclProvider extends Stmt {
123123 result = this .( ImportDeclaration ) .getASpecifier ( ) .getLocal ( ) or
124124 result = this .( ImportEqualsDeclaration ) .getId ( )
125125 }
126+
127+ /**
128+ * Gets an unacceptable unused variable declared by this import.
129+ */
130+ UnusedLocal getAnUnacceptableUnusedLocal ( ) {
131+ result = getAVarDecl ( ) .getVariable ( ) and
132+ not whitelisted ( result )
133+ }
134+
126135}
127136
128137/**
@@ -167,17 +176,13 @@ predicate unusedNonImports(VarDecl vd, string msg) {
167176 */
168177predicate unusedImports ( ImportVarDeclProvider provider , string msg ) {
169178 exists ( string plural , string names |
170- names = concat ( UnusedLocal v |
171- v = provider .getAVarDecl ( ) .getVariable ( ) and
172- not whitelisted ( v ) |
179+ names = strictconcat ( UnusedLocal v |
180+ v = provider .getAnUnacceptableUnusedLocal ( ) |
173181 v .getName ( ) ,
174182 ", " order by v .getName ( )
175183 ) and
176- not names = "" and
177184 (
178- if count ( UnusedLocal v |
179- v = provider .getAVarDecl ( ) .getVariable ( ) and
180- not whitelisted ( v ) ) > 1 then
185+ if count ( provider .getAnUnacceptableUnusedLocal ( ) ) > 1 then
181186 plural = "s"
182187 else
183188 plural = ""
You can’t perform that action at this time.
0 commit comments