File tree Expand file tree Collapse file tree 4 files changed +11
-14
lines changed
test/queries/style/ImplicitThis Expand file tree Collapse file tree 4 files changed +11
-14
lines changed Original file line number Diff line number Diff line change 1
1
import ql
2
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
3
PredicateCall implicitThisCallInFile ( File f ) {
11
4
result .getLocation ( ) .getFile ( ) = f and
12
5
exists ( result .getTarget ( ) .getDeclaringType ( ) .getASuperType ( ) ) and
13
6
// Exclude `SomeModule::whatever(...)`
14
7
not exists ( result .getQualifier ( ) )
15
8
}
16
9
17
- PredicateCall confusingImplicitThisCall ( File f ) {
18
- result = implicitThisCallInFile ( f ) and
19
- exists ( explicitThisCallInFile ( f ) )
20
- }
10
+ PredicateCall confusingImplicitThisCall ( File f ) { result = implicitThisCallInFile ( f ) }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
1
+ | Bad2.qll:8:41:8:48 | PredicateCall | Use of implicit `this`. |
1
2
| Bad.qll:10:41:10:48 | PredicateCall | Use of implicit `this`. |
Original file line number Diff line number Diff line change @@ -5,9 +5,6 @@ class Foo extends string {
5
5
6
6
string getBar ( ) { result = "bar" }
7
7
8
- /* Okay, because we don't write `this.some_method` anywhere */
9
- string getBarWithoutThis ( ) { result = getBar ( ) }
10
-
11
8
/* Okay, because this is the only way to cast `this`. */
12
9
string useThisWithInlineCast ( ) { result = this .( string ) .toUpperCase ( ) }
13
10
}
You can’t perform that action at this time.
0 commit comments