Skip to content

Commit 2e44fba

Browse files
committed
add explicit this
1 parent b9823cf commit 2e44fba

File tree

13 files changed

+45
-39
lines changed

13 files changed

+45
-39
lines changed

cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,11 @@ class PathElement extends TPathElement {
268268
predicate isSink(IRBlock block) { exists(this.asSink(block)) }
269269

270270
string toString() {
271-
result = [asStore().toString(), asCall(_).toString(), asMid().toString(), asSink(_).toString()]
271+
result =
272+
[
273+
this.asStore().toString(), this.asCall(_).toString(), this.asMid().toString(),
274+
this.asSink(_).toString()
275+
]
272276
}
273277

274278
predicate hasLocationInfo(

go/ql/lib/semmle/go/AST.qll

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class AstNode extends @node, Locatable {
2828
/**
2929
* Gets a child node of this node.
3030
*/
31-
AstNode getAChild() { result = getChild(_) }
31+
AstNode getAChild() { result = this.getChild(_) }
3232

3333
/**
3434
* Gets the number of child nodes of this node.
3535
*/
36-
int getNumChild() { result = count(getAChild()) }
36+
int getNumChild() { result = count(this.getAChild()) }
3737

3838
/**
3939
* Gets a child with the given index and of the given kind, if one exists.
@@ -63,7 +63,7 @@ class AstNode extends @node, Locatable {
6363
AstNode getUniquelyNumberedChild(int index) {
6464
result =
6565
rank[index + 1](AstNode child, string kind, int i |
66-
child = getChildOfKind(kind, i)
66+
child = this.getChildOfKind(kind, i)
6767
|
6868
child order by kind, i
6969
)
@@ -74,17 +74,17 @@ class AstNode extends @node, Locatable {
7474

7575
/** Gets the parent node of this AST node, but without crossing function boundaries. */
7676
private AstNode parentInSameFunction() {
77-
result = getParent() and
77+
result = this.getParent() and
7878
not this instanceof FuncDef
7979
}
8080

8181
/** Gets the innermost function definition to which this AST node belongs, if any. */
82-
FuncDef getEnclosingFunction() { result = getParent().parentInSameFunction*() }
82+
FuncDef getEnclosingFunction() { result = this.getParent().parentInSameFunction*() }
8383

8484
/**
8585
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
8686
*/
87-
final string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
87+
final string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") }
8888

8989
/**
9090
* Gets the name of a primary CodeQL class to which this node belongs.
@@ -116,12 +116,12 @@ class ExprParent extends @exprparent, AstNode {
116116
/**
117117
* Gets an expression that is a child node of this node in the AST.
118118
*/
119-
Expr getAChildExpr() { result = getChildExpr(_) }
119+
Expr getAChildExpr() { result = this.getChildExpr(_) }
120120

121121
/**
122122
* Gets the number of child expressions of this node.
123123
*/
124-
int getNumChildExpr() { result = count(getAChildExpr()) }
124+
int getNumChildExpr() { result = count(this.getAChildExpr()) }
125125
}
126126

127127
/**
@@ -139,12 +139,12 @@ class GoModExprParent extends @modexprparent, AstNode {
139139
/**
140140
* Gets an expression that is a child node of this node in the AST.
141141
*/
142-
GoModExpr getAChildGoModExpr() { result = getChildGoModExpr(_) }
142+
GoModExpr getAChildGoModExpr() { result = this.getChildGoModExpr(_) }
143143

144144
/**
145145
* Gets the number of child expressions of this node.
146146
*/
147-
int getNumChildGoModExpr() { result = count(getAChildGoModExpr()) }
147+
int getNumChildGoModExpr() { result = count(this.getAChildGoModExpr()) }
148148
}
149149

150150
/**
@@ -162,12 +162,12 @@ class StmtParent extends @stmtparent, AstNode {
162162
/**
163163
* Gets a statement that is a child node of this node in the AST.
164164
*/
165-
Stmt getAChildStmt() { result = getChildStmt(_) }
165+
Stmt getAChildStmt() { result = this.getChildStmt(_) }
166166

167167
/**
168168
* Gets the number of child statements of this node.
169169
*/
170-
int getNumChildStmt() { result = count(getAChildStmt()) }
170+
int getNumChildStmt() { result = count(this.getAChildStmt()) }
171171
}
172172

173173
/**
@@ -185,12 +185,12 @@ class DeclParent extends @declparent, AstNode {
185185
/**
186186
* Gets a child declaration of this node in the AST.
187187
*/
188-
Decl getADecl() { result = getDecl(_) }
188+
Decl getADecl() { result = this.getDecl(_) }
189189

190190
/**
191191
* Gets the number of child declarations of this node.
192192
*/
193-
int getNumDecl() { result = count(getADecl()) }
193+
int getNumDecl() { result = count(this.getADecl()) }
194194
}
195195

196196
/**
@@ -208,12 +208,12 @@ class FieldParent extends @fieldparent, AstNode {
208208
/**
209209
* Gets a child field of this node in the AST.
210210
*/
211-
FieldBase getAField() { result = getField(_) }
211+
FieldBase getAField() { result = this.getField(_) }
212212

213213
/**
214214
* Gets the number of child fields of this node.
215215
*/
216-
int getNumFields() { result = count(getAField()) }
216+
int getNumFields() { result = count(this.getAField()) }
217217
}
218218

219219
/**

go/ql/lib/semmle/go/Types.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ class InterfaceType extends @interfacetype, CompositeType {
787787
* Note that the indexes are not contiguous.
788788
*/
789789
TypeSetLiteralType getDirectlyEmbeddedTypeSetLiteral(int index) {
790-
hasDirectlyEmbeddedType(index, result)
790+
this.hasDirectlyEmbeddedType(index, result)
791791
}
792792

793793
/**
@@ -798,7 +798,7 @@ class InterfaceType extends @interfacetype, CompositeType {
798798
TypeSetLiteralType getAnEmbeddedTypeSetLiteral() {
799799
result = this.getDirectlyEmbeddedTypeSetLiteral(_) or
800800
result =
801-
getADirectlyEmbeddedInterface()
801+
this.getADirectlyEmbeddedInterface()
802802
.getUnderlyingType()
803803
.(InterfaceType)
804804
.getAnEmbeddedTypeSetLiteral()

java/ql/lib/semmle/code/java/frameworks/android/SQLite.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,23 @@ private import semmle.code.java.frameworks.android.Android
99
* The class `android.database.sqlite.SQLiteDatabase`.
1010
*/
1111
class TypeSQLiteDatabase extends Class {
12-
TypeSQLiteDatabase() { hasQualifiedName("android.database.sqlite", "SQLiteDatabase") }
12+
TypeSQLiteDatabase() { this.hasQualifiedName("android.database.sqlite", "SQLiteDatabase") }
1313
}
1414

1515
/**
1616
* The class `android.database.sqlite.SQLiteQueryBuilder`.
1717
*/
1818
class TypeSQLiteQueryBuilder extends Class {
19-
TypeSQLiteQueryBuilder() { hasQualifiedName("android.database.sqlite", "SQLiteQueryBuilder") }
19+
TypeSQLiteQueryBuilder() {
20+
this.hasQualifiedName("android.database.sqlite", "SQLiteQueryBuilder")
21+
}
2022
}
2123

2224
/**
2325
* The class `android.database.DatabaseUtils`.
2426
*/
2527
class TypeDatabaseUtils extends Class {
26-
TypeDatabaseUtils() { hasQualifiedName("android.database", "DatabaseUtils") }
28+
TypeDatabaseUtils() { this.hasQualifiedName("android.database", "DatabaseUtils") }
2729
}
2830

2931
/**

java/ql/src/Security/CWE/CWE-200/TempDirUtils.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private class FileSetRedableMethodAccess extends MethodAccess {
5353
private predicate isCallToSecondArgumentWithValue(boolean value) {
5454
this.getMethod().getNumberOfParameters() = 1 and value = true
5555
or
56-
isCallWithArgument(1, value)
56+
this.isCallWithArgument(1, value)
5757
}
5858

5959
private predicate isCallWithArgument(int index, boolean arg) {

python/ql/test/TestUtilities/VerifyApiGraphs.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class Assertion extends Comment {
8484
string tryExplainFailure() {
8585
exists(int i, API::Node nd, string prefix, string suffix |
8686
nd = this.lookup(i) and
87-
i < getPathLength() and
88-
not exists(this.lookup([i + 1 .. getPathLength()])) and
87+
i < this.getPathLength() and
88+
not exists(this.lookup([i + 1 .. this.getPathLength()])) and
8989
prefix = nd + " has no outgoing edge labelled " + this.getEdgeLabel(i) + ";" and
9090
if exists(nd.getASuccessor())
9191
then

python/tools/recorded-call-graph-metrics/ql/lib/RecordedCalls.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class XmlRecordedCall extends XMLElement {
1111
XmlCall getXmlCall() { result.getParent() = this }
1212

1313
/** DEPRECATED: Alias for getXmlCall */
14-
deprecated XMLCall getXMLCall() { result = getXmlCall() }
14+
deprecated XMLCall getXMLCall() { result = this.getXmlCall() }
1515

1616
/** Gets a call matching the recorded information. */
1717
Call getACall() { result = this.getXmlCall().getACall() }
@@ -20,7 +20,7 @@ class XmlRecordedCall extends XMLElement {
2020
XmlCallee getXmlCallee() { result.getParent() = this }
2121

2222
/** DEPRECATED: Alias for getXmlCallee */
23-
deprecated XMLCallee getXMLCallee() { result = getXmlCallee() }
23+
deprecated XMLCallee getXMLCallee() { result = this.getXmlCallee() }
2424

2525
/** Gets a python function matching the recorded information of the callee. */
2626
Function getAPythonCallee() { result = this.getXmlCallee().(XmlPythonCallee).getACallee() }
@@ -90,10 +90,10 @@ class XmlCall extends XMLElement {
9090
expr.(Name).getId() = bytecode.(XmlBytecodeVariableName).get_name_data()
9191
or
9292
expr.(Attribute).getName() = bytecode.(XmlBytecodeAttribute).get_attr_name_data() and
93-
matchBytecodeExpr(expr.(Attribute).getObject(),
93+
this.matchBytecodeExpr(expr.(Attribute).getObject(),
9494
bytecode.(XmlBytecodeAttribute).get_object_data())
9595
or
96-
matchBytecodeExpr(expr.(Call).getFunc(), bytecode.(XmlBytecodeCall).get_function_data())
96+
this.matchBytecodeExpr(expr.(Call).getFunc(), bytecode.(XmlBytecodeCall).get_function_data())
9797
//
9898
// I considered allowing a partial match as well. That is, if the bytecode
9999
// expression information only tells us `<unknown>.foo()`, and we find an AST

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private module ParameterNodes {
176176
)
177177
}
178178

179-
override DataFlowCallable getEnclosingCallable() { isParameterOf(result, _) }
179+
override DataFlowCallable getEnclosingCallable() { this.isParameterOf(result, _) }
180180
}
181181
}
182182

swift/ql/lib/codeql/swift/elements/Comment.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ private import codeql.swift.generated.Comment
22

33
class Comment extends CommentBase {
44
/** toString */
5-
override string toString() { result = getText() }
5+
override string toString() { result = this.getText() }
66
}
77

88
class SingleLineComment extends Comment {

swift/ql/lib/codeql/swift/elements/Element.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ private import codeql.swift.generated.Element
33
class Element extends ElementBase {
44
private predicate resolvesFrom(Element e) { e.getResolveStep() = this }
55

6-
override string toString() { result = getPrimaryQlClasses() }
6+
override string toString() { result = this.getPrimaryQlClasses() }
77

88
Element getFullyUnresolved() {
99
not this.resolvesFrom(_) and result = this
@@ -16,5 +16,5 @@ class Element extends ElementBase {
1616
}
1717

1818
class UnknownElement extends Element {
19-
UnknownElement() { isUnknown() }
19+
UnknownElement() { this.isUnknown() }
2020
}

0 commit comments

Comments
 (0)