Skip to content

Commit 28444c7

Browse files
committed
QL: move implementation of implicit-this to Query.qll file
1 parent c3f3628 commit 28444c7

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import ql
2+
3+
MemberCall explicitThisCallInFile(File f) {
4+
result.getLocation().getFile() = f and
5+
result.getBase() instanceof ThisAccess and
6+
// Exclude `this.(Type).whatever(...)`, as some files have that as their only instance of `this`.
7+
not result = any(InlineCast c).getBase()
8+
}
9+
10+
PredicateCall implicitThisCallInFile(File f) {
11+
result.getLocation().getFile() = f and
12+
exists(result.getTarget().getDeclaringType().getASuperType()) and
13+
// Exclude `SomeModule::whatever(...)`
14+
not exists(result.getQualifier())
15+
}
16+
17+
PredicateCall confusingImplicitThisCall(File f) {
18+
result = implicitThisCallInFile(f) and
19+
exists(explicitThisCallInFile(f))
20+
}

ql/src/queries/style/ImplicitThis.ql

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,7 @@
99
*/
1010

1111
import ql
12-
13-
MemberCall explicitThisCallInFile(File f) {
14-
result.getLocation().getFile() = f and
15-
result.getBase() instanceof ThisAccess and
16-
// Exclude `this.(Type).whatever(...)`, as some files have that as their only instance of `this`.
17-
not result = any(InlineCast c).getBase()
18-
}
19-
20-
PredicateCall implicitThisCallInFile(File f) {
21-
result.getLocation().getFile() = f and
22-
exists(result.getTarget().getDeclaringType().getASuperType()) and
23-
// Exclude `SomeModule::whatever(...)`
24-
not exists(result.getQualifier())
25-
}
26-
27-
PredicateCall confusingImplicitThisCall(File f) {
28-
result = implicitThisCallInFile(f) and
29-
exists(explicitThisCallInFile(f))
30-
}
12+
import codeql_ql.style.ImplicitThisQuery
3113

3214
from PredicateCall c
3315
where c = confusingImplicitThisCall(_)

0 commit comments

Comments
 (0)