Skip to content

Commit b8be1bc

Browse files
asgerfNapalys
authored andcommitted
JS: Avoid duplication with constructor body
1 parent c430a36 commit b8be1bc

File tree

3 files changed

+1
-2
lines changed

3 files changed

+1
-2
lines changed

javascript/ql/lib/semmle/javascript/dataflow/Nodes.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ class ClassNode extends DataFlow::ValueNode, DataFlow::SourceNode {
872872
or
873873
// Function-style class case
874874
astNode instanceof Function and
875+
not astNode = any(ClassDefinition cls).getConstructor().getBody() and
875876
function.getFunction() = astNode and
876877
(
877878
exists(getAFunctionValueWithPrototype(function))

javascript/ql/test/library-tests/ClassNode/tests.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ getAReceiverNode
1515
| tst.js:3:1:10:1 | class A ... () {}\\n} | tst.js:4:17:4:16 | this |
1616
| tst.js:3:1:10:1 | class A ... () {}\\n} | tst.js:7:6:7:5 | this |
1717
| tst.js:3:1:10:1 | class A ... () {}\\n} | tst.js:9:10:9:9 | this |
18-
| tst.js:3:9:3:8 | () {} | tst.js:3:9:3:8 | this |
1918
| tst.js:13:1:13:21 | class A ... ds A {} | tst.js:13:20:13:19 | this |
2019
| tst.js:15:1:15:15 | function B() {} | tst.js:15:1:15:0 | this |
2120
| tst.js:15:1:15:15 | function B() {} | tst.js:17:19:17:18 | this |

javascript/ql/test/library-tests/Classes/tests.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ test_ConstructorDefinitions
194194
| tst.js:11:9:11:8 | constructor() {} |
195195
test_ClassNodeConstructor
196196
| dataflow.js:4:2:13:2 | class F ... \\n\\t\\t}\\n\\t} | dataflow.js:4:12:4:11 | () {} |
197-
| dataflow.js:4:12:4:11 | () {} | dataflow.js:4:12:4:11 | () {} |
198197
| fields.js:1:1:4:1 | class C ... = 42\\n} | fields.js:1:9:1:8 | () {} |
199198
| points.js:1:1:18:1 | class P ... ;\\n }\\n} | points.js:2:14:5:3 | (x, y) ... y;\\n } |
200199
| points.js:20:1:33:1 | class C ... ;\\n }\\n} | points.js:21:14:24:3 | (x, y, ... c;\\n } |

0 commit comments

Comments
 (0)