Skip to content

Commit 57b4534

Browse files
committed
JS: Avoid overriding Expr predicates in xUnit.qll
1 parent b4d6cb6 commit 57b4534

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

javascript/ql/lib/semmle/javascript/frameworks/xUnit.qll

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ private predicate possiblyAttribute(Expr e, string name) {
2323
)
2424
}
2525

26+
final private class FinalExpr = Expr;
27+
2628
/**
2729
* A bracketed list of expressions.
2830
*
@@ -34,15 +36,22 @@ private predicate possiblyAttribute(Expr e, string name) {
3436
*
3537
* We also allow singleton lists, as in `[a][b]`.
3638
*/
37-
abstract private class BracketedListOfExpressions extends Expr {
39+
abstract private class BracketedListOfExpressions extends FinalExpr {
3840
/** Gets the `i`th element expression of this list. */
3941
abstract Expr getElement(int i);
42+
43+
/** Gets the first token in this bracketed list of expressions */
44+
Token getFirstToken() { result = Expr.super.getFirstToken() }
45+
46+
/** Gets the last token in this bracketed list of expressions */
47+
Token getLastToken() { result = Expr.super.getLastToken() }
4048
}
4149

4250
/**
4351
* An array expression viewed as a bracketed list of expressions.
4452
*/
45-
private class ArrayExprIsABracketedListOfExpressions extends ArrayExpr, BracketedListOfExpressions {
53+
private class ArrayExprIsABracketedListOfExpressions extends BracketedListOfExpressions instanceof ArrayExpr
54+
{
4655
/** Gets the `i`th element of this array literal. */
4756
override Expr getElement(int i) { result = ArrayExpr.super.getElement(i) }
4857
}

javascript/ql/test/library-tests/frameworks/xUnit/tests.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ xUnitAnnotationfrom
33
| tst.js:5:5:5:13 | [Fixture] | tst.js:6:5:13:5 | functio ... }\\n } |
44
| tst.js:7:9:7:14 | [Fact] | tst.js:8:9:12:9 | functio ... } |
55
| tst.js:16:1:16:43 | [Import ... t.js")] | tst.js:18:1:22:2 | Test.xU ... ..]\\n\\n}; |
6-
| tst.js:17:1:17:9 | Fixture | tst.js:18:1:22:2 | Test.xU ... ..]\\n\\n}; |
6+
| tst.js:17:2:17:8 | Fixture | tst.js:18:1:22:2 | Test.xU ... ..]\\n\\n}; |
77
| tst.js:24:1:24:9 | [Fixture] | tst.js:25:1:34:2 | Test.Ex ... }\\n}; |
88
| tst.js:27:5:29:7 | [Import ... })] | tst.js:31:5:33:5 | functio ... ]\\n } |
9-
| tst.js:30:5:30:10 | Fact | tst.js:31:5:33:5 | functio ... ]\\n } |
9+
| tst.js:30:6:30:9 | Fact | tst.js:31:5:33:5 | functio ... ]\\n } |
1010
xUnitAttribute
1111
| tst.js:3:2:3:8 | Fixture | Fixture | 0 |
1212
| tst.js:5:6:5:12 | Fixture | Fixture | 0 |
@@ -24,7 +24,7 @@ xUnitFixture
2424
| tst.js:4:20:14:1 | functio ... }\\n} | tst.js:3:1:3:9 | [Fixture] |
2525
| tst.js:6:5:13:5 | functio ... }\\n } | tst.js:5:5:5:13 | [Fixture] |
2626
| tst.js:18:24:22:1 | functio ... ...]\\n\\n} | tst.js:16:1:16:43 | [Import ... t.js")] |
27-
| tst.js:18:24:22:1 | functio ... ...]\\n\\n} | tst.js:17:1:17:9 | Fixture |
27+
| tst.js:18:24:22:1 | functio ... ...]\\n\\n} | tst.js:17:2:17:8 | Fixture |
2828
| tst.js:25:21:34:1 | functio ... }\\n} | tst.js:24:1:24:9 | [Fixture] |
2929
xUnitTarget
3030
| tst.js:4:1:14:2 | Test.Ex ... }\\n}; |

0 commit comments

Comments
 (0)