Skip to content

Commit 89b91af

Browse files
committed
JS: Make getDocumentation handle chain assignments
1 parent 61034be commit 89b91af

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

javascript/ql/src/semmle/javascript/Expr.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ class ExprOrType extends @exprortype, Documentable {
5555
exists(DotExpr dot | this = dot.getProperty() |
5656
result = dot.getDocumentation()
5757
)
58+
or
59+
exists(AssignExpr e | this = e.getRhs() |
60+
result = e.getDocumentation()
61+
)
62+
or
63+
exists(ParExpr p | this = p.getExpression() |
64+
result = p.getDocumentation()
65+
)
5866
)
5967
}
6068

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
| tst.js:4:4:4:9 | @param | @param tag refers to non-existent parameter prameter. |
22
| tst.js:12:4:12:9 | @param | @param tag refers to non-existent parameter sign. |
3+
| tst.js:51:4:51:9 | @param | @param tag refers to non-existent parameter opts. |
4+
| tst.js:57:4:57:9 | @param | @param tag refers to non-existent parameter opts. |

javascript/ql/test/query-tests/JSDoc/JSDocForNonExistentParameter/tst.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,16 @@ function good3() {
4545
lastName = arguments[0];
4646
}
4747
return firstName + sep + lastName;
48-
}
48+
}
49+
50+
/**
51+
* @param {IncomingMessage} opts
52+
*/
53+
var Cookie = foo.bar = function Cookie(options) {
54+
}
55+
56+
/**
57+
* @param {IncomingMessage} opts
58+
*/
59+
Cookie2 = foo.bar2 = function Cookie2(options) {
60+
}

0 commit comments

Comments
 (0)