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 11import 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-
103PredicateCall 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 ) }
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`. |
12| 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 {
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}
You can’t perform that action at this time.
0 commit comments