File tree Expand file tree Collapse file tree
test/query-tests/Expressions/SelfAssignment Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -152,7 +152,14 @@ class SelfAssignment extends StructurallyCompared {
152152 }
153153
154154 override Expr candidate ( ) {
155- result = getParent ( ) .( AssignExpr ) .getRhs ( )
155+ result = getAssignment ( ) .getRhs ( )
156+ }
157+
158+ /**
159+ * Gets the enclosing assignment.
160+ */
161+ AssignExpr getAssignment ( ) {
162+ result .getLhs ( ) = this
156163 }
157164}
158165
Original file line number Diff line number Diff line change @@ -43,5 +43,7 @@ where e.same(_) and
4343 propName = any ( AccessorMethodDeclaration amd ) .getName ( )
4444 ) and
4545 // exclude DOM properties
46- not isDOMProperty ( e .( PropAccess ) .getPropertyName ( ) )
47- select e .getParent ( ) , "This expression assigns " + dsc + " to itself."
46+ not isDOMProperty ( e .( PropAccess ) .getPropertyName ( ) ) and
47+ // exclude self-assignments with a JSDoc comment
48+ not exists ( e .getAssignment ( ) .getParent ( ) .( ExprStmt ) .getDocumentation ( ) .getATag ( ) )
49+ select e .getParent ( ) , "This expression assigns " + dsc + " to itself."
Original file line number Diff line number Diff line change 1+ | jsdoc.js:9:5:9:19 | this.y = this.y | This expression assigns property y to itself. |
2+ | jsdoc.js:11:5:11:23 | this.arg = this.arg | This expression assigns property arg to itself. |
13| tst.js:5:2:5:14 | width = width | This expression assigns variable width to itself. |
24| tst.js:24:1:24:19 | array[1] = array[1] | This expression assigns element 1 to itself. |
35| tst.js:27:1:27:9 | o.x = o.x | This expression assigns property x to itself. |
Original file line number Diff line number Diff line change 1+ class C extends Q {
2+ constructor ( arg ) {
3+ /**
4+ * Something.
5+ * @type {string | undefined }
6+ */
7+ this . x = this . x ; // OK - documentation
8+
9+ this . y = this . y ; // NOT OK
10+
11+ this . arg = this . arg ; // NOT OK
12+ }
13+ }
14+
15+ // semmle-extractor-options: --experimental
You can’t perform that action at this time.
0 commit comments