Skip to content

Commit a920c13

Browse files
committed
Remove ql/implicit-this restriction to files with explicit this
1 parent 082e6a1 commit a920c13

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
import ql
22

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-
103
PredicateCall implicitThisCallInFile(File f) {
114
result.getLocation().getFile() = f and
125
exists(result.getTarget().getDeclaringType().getASuperType()) and
136
// Exclude `SomeModule::whatever(...)`
147
not exists(result.getQualifier())
158
}
169

17-
PredicateCall confusingImplicitThisCall(File f) {
18-
result = implicitThisCallInFile(f) and
19-
exists(explicitThisCallInFile(f))
20-
}
10+
PredicateCall confusingImplicitThisCall(File f) { result = implicitThisCallInFile(f) }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import ql
2+
3+
class Foo extends string {
4+
Foo() { this = "hello" }
5+
6+
string getBar() { result = "bar" }
7+
8+
string getBarWithoutThis() { result = getBar() }
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
| Bad2.qll:8:41:8:48 | PredicateCall | Use of implicit `this`. |
12
| Bad.qll:10:41:10:48 | PredicateCall | Use of implicit `this`. |

ql/ql/test/queries/style/ImplicitThis/Okay.qll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ class Foo extends string {
55

66
string getBar() { result = "bar" }
77

8-
/* Okay, because we don't write `this.some_method` anywhere */
9-
string getBarWithoutThis() { result = getBar() }
10-
118
/* Okay, because this is the only way to cast `this`. */
129
string useThisWithInlineCast() { result = this.(string).toUpperCase() }
1310
}

0 commit comments

Comments
 (0)