mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
JS: Avoid having multiple names again
This commit is contained in:
@@ -220,17 +220,20 @@ class ClassExpr extends @classexpr, ClassDefinition, Expr {
|
||||
override string getName() {
|
||||
result = ClassDefinition.super.getName()
|
||||
or
|
||||
exists(VarDef vd | this = vd.getSource() | result = vd.getTarget().(VarRef).getName())
|
||||
or
|
||||
exists(Property p |
|
||||
this = p.getInit() and
|
||||
result = p.getName()
|
||||
)
|
||||
or
|
||||
exists(AssignExpr assign, DotExpr prop |
|
||||
this = assign.getRhs().getUnderlyingValue() and
|
||||
prop = assign.getLhs() and
|
||||
result = prop.getPropertyName()
|
||||
not exists(getIdentifier()) and
|
||||
(
|
||||
exists(VarDef vd | this = vd.getSource() | result = vd.getTarget().(VarRef).getName())
|
||||
or
|
||||
exists(Property p |
|
||||
this = p.getInit() and
|
||||
result = p.getName()
|
||||
)
|
||||
or
|
||||
exists(AssignExpr assign, DotExpr prop |
|
||||
this = assign.getRhs().getUnderlyingValue() and
|
||||
prop = assign.getLhs() and
|
||||
result = prop.getPropertyName()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -58,20 +58,23 @@ class Function extends @function, Parameterized, TypeParameterized, StmtContaine
|
||||
string getName() {
|
||||
result = getId().getName()
|
||||
or
|
||||
exists(VarDef vd | this = vd.getSource() | result = vd.getTarget().(VarRef).getName())
|
||||
or
|
||||
exists(Property p |
|
||||
this = p.getInit() and
|
||||
result = p.getName()
|
||||
not exists(getId()) and
|
||||
(
|
||||
exists(VarDef vd | this = vd.getSource() | result = vd.getTarget().(VarRef).getName())
|
||||
or
|
||||
exists(Property p |
|
||||
this = p.getInit() and
|
||||
result = p.getName()
|
||||
)
|
||||
or
|
||||
exists(AssignExpr assign, DotExpr prop |
|
||||
this = assign.getRhs().getUnderlyingValue() and
|
||||
prop = assign.getLhs() and
|
||||
result = prop.getPropertyName()
|
||||
)
|
||||
or
|
||||
exists(ClassOrInterface c | this = c.getMember(result).getInit())
|
||||
)
|
||||
or
|
||||
exists(AssignExpr assign, DotExpr prop |
|
||||
this = assign.getRhs().getUnderlyingValue() and
|
||||
prop = assign.getLhs() and
|
||||
result = prop.getPropertyName()
|
||||
)
|
||||
or
|
||||
exists(ClassOrInterface c | this = c.getMember(result).getInit())
|
||||
}
|
||||
|
||||
/** Gets the variable holding this function. */
|
||||
|
||||
@@ -104,7 +104,6 @@ test_getId
|
||||
| tst.js:1:1:1:15 | function A() {} | tst.js:1:10:1:10 | A | A |
|
||||
| tst.js:2:1:2:16 | function B(x) {} | tst.js:2:10:2:10 | B | B |
|
||||
| tst.js:3:1:3:19 | function C(x, y) {} | tst.js:3:10:3:10 | C | C |
|
||||
| tst.js:7:9:7:23 | function h() {} | tst.js:7:18:7:18 | h | g |
|
||||
| tst.js:7:9:7:23 | function h() {} | tst.js:7:18:7:18 | h | h |
|
||||
| tst.js:9:1:9:24 | functio ... nts) {} | tst.js:9:10:9:10 | k | k |
|
||||
| tst.js:10:1:10:31 | functio ... ents; } | tst.js:10:10:10:10 | l | l |
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
| tst.ts | ESNamedExport1 | esNamedExports.ts | ESNamedExport1 |
|
||||
| tst.ts | ESNamedExport2 | esNamedExports.ts | ESNamedExport2 |
|
||||
| tst.ts | NodeFullExport | nodeFullExport.ts | NodeFullExport |
|
||||
| tst.ts | NodeFullExport | nodeFullExport.ts | exports |
|
||||
| tst.ts | NodeNamedExport | nodeNamedExport.ts | NodeNamedExport |
|
||||
|
||||
@@ -2,7 +2,6 @@ getName
|
||||
| tst.js:16:1:19:1 | class C ... ss C"\\n} | C |
|
||||
| tst.js:21:2:23:1 | class D ... lass"\\n} | D |
|
||||
| tst.js:25:11:25:18 | class {} | E |
|
||||
| tst.js:26:11:29:1 | class G ... ss G"\\n} | F |
|
||||
| tst.js:26:11:29:1 | class G ... ss G"\\n} | G |
|
||||
| tst.js:34:9:34:16 | class {} | Foo |
|
||||
#select
|
||||
|
||||
@@ -3,11 +3,9 @@ getName
|
||||
| tst.js:2:2:2:16 | function g() {} | g |
|
||||
| tst.js:4:9:4:22 | function () {} | h |
|
||||
| tst.js:5:9:5:14 | x => x | k |
|
||||
| tst.js:6:9:6:23 | function n() {} | m |
|
||||
| tst.js:6:9:6:23 | function n() {} | n |
|
||||
| tst.js:9:6:9:18 | function() {} | p |
|
||||
| tst.js:10:6:10:20 | function f() {} | f |
|
||||
| tst.js:10:6:10:20 | function f() {} | q |
|
||||
| tst.js:11:8:11:12 | () {} | x |
|
||||
| tst.js:12:8:12:13 | (v) {} | x |
|
||||
| tst.js:13:4:13:8 | () {} | m |
|
||||
|
||||
Reference in New Issue
Block a user