Skip to content

Commit caeeebf

Browse files
committed
add explicit this qualifier on all of java
1 parent b2e4276 commit caeeebf

File tree

104 files changed

+1269
-1172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1269
-1172
lines changed

java/ql/lib/external/ExternalArtifact.qll

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@ import java
33
class ExternalData extends @externalDataElement {
44
string getDataPath() { externalData(this, result, _, _) }
55

6-
string getQueryPath() { result = getDataPath().regexpReplaceAll("\\.[^.]*$", ".ql") }
6+
string getQueryPath() { result = this.getDataPath().regexpReplaceAll("\\.[^.]*$", ".ql") }
77

88
int getNumFields() { result = 1 + max(int i | externalData(this, _, i, _) | i) }
99

1010
string getField(int index) { externalData(this, _, index, result) }
1111

12-
int getFieldAsInt(int index) { result = getField(index).toInt() }
12+
int getFieldAsInt(int index) { result = this.getField(index).toInt() }
1313

14-
float getFieldAsFloat(int index) { result = getField(index).toFloat() }
14+
float getFieldAsFloat(int index) { result = this.getField(index).toFloat() }
1515

16-
date getFieldAsDate(int index) { result = getField(index).toDate() }
16+
date getFieldAsDate(int index) { result = this.getField(index).toDate() }
1717

18-
string toString() { result = getQueryPath() + ": " + buildTupleString(0) }
18+
string toString() { result = this.getQueryPath() + ": " + this.buildTupleString(0) }
1919

2020
private string buildTupleString(int start) {
21-
start = getNumFields() - 1 and result = getField(start)
21+
start = this.getNumFields() - 1 and result = this.getField(start)
2222
or
23-
start < getNumFields() - 1 and result = getField(start) + "," + buildTupleString(start + 1)
23+
start < this.getNumFields() - 1 and
24+
result = this.getField(start) + "," + this.buildTupleString(start + 1)
2425
}
2526
}
2627

@@ -33,7 +34,7 @@ class DefectExternalData extends ExternalData {
3334
this.getNumFields() = 2
3435
}
3536

36-
string getURL() { result = getField(0) }
37+
string getURL() { result = this.getField(0) }
3738

38-
string getMessage() { result = getField(1) }
39+
string getMessage() { result = this.getField(1) }
3940
}

java/ql/lib/semmle/code/FileSystem.qll

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Container extends @container, Top {
4747
*/
4848
string getRelativePath() {
4949
exists(string absPath, string pref |
50-
absPath = getAbsolutePath() and sourceLocationPrefix(pref)
50+
absPath = this.getAbsolutePath() and sourceLocationPrefix(pref)
5151
|
5252
absPath = pref and result = ""
5353
or
@@ -74,7 +74,7 @@ class Container extends @container, Top {
7474
* </table>
7575
*/
7676
string getBaseName() {
77-
result = getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", 1)
77+
result = this.getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", 1)
7878
}
7979

8080
/**
@@ -100,7 +100,9 @@ class Container extends @container, Top {
100100
* <tr><td>"/tmp/x.tar.gz"</td><td>"gz"</td></tr>
101101
* </table>
102102
*/
103-
string getExtension() { result = getAbsolutePath().regexpCapture(".*/([^/]*?)(\\.([^.]*))?", 3) }
103+
string getExtension() {
104+
result = this.getAbsolutePath().regexpCapture(".*/([^/]*?)(\\.([^.]*))?", 3)
105+
}
104106

105107
/**
106108
* Gets the stem of this container, that is, the prefix of its base name up to
@@ -119,7 +121,9 @@ class Container extends @container, Top {
119121
* <tr><td>"/tmp/x.tar.gz"</td><td>"x.tar"</td></tr>
120122
* </table>
121123
*/
122-
string getStem() { result = getAbsolutePath().regexpCapture(".*/([^/]*?)(?:\\.([^.]*))?", 1) }
124+
string getStem() {
125+
result = this.getAbsolutePath().regexpCapture(".*/([^/]*?)(?:\\.([^.]*))?", 1)
126+
}
123127

124128
/** Gets the parent container of this file or folder, if any. */
125129
Container getParentContainer() { containerparent(result, this) }
@@ -128,20 +132,20 @@ class Container extends @container, Top {
128132
Container getAChildContainer() { this = result.getParentContainer() }
129133

130134
/** Gets a file in this container. */
131-
File getAFile() { result = getAChildContainer() }
135+
File getAFile() { result = this.getAChildContainer() }
132136

133137
/** Gets the file in this container that has the given `baseName`, if any. */
134138
File getFile(string baseName) {
135-
result = getAFile() and
139+
result = this.getAFile() and
136140
result.getBaseName() = baseName
137141
}
138142

139143
/** Gets a sub-folder in this container. */
140-
Folder getAFolder() { result = getAChildContainer() }
144+
Folder getAFolder() { result = this.getAChildContainer() }
141145

142146
/** Gets the sub-folder in this container that has the given `baseName`, if any. */
143147
Folder getFolder(string baseName) {
144-
result = getAFolder() and
148+
result = this.getAFolder() and
145149
result.getBaseName() = baseName
146150
}
147151

@@ -152,15 +156,15 @@ class Container extends @container, Top {
152156
* to provide a different result. To get the absolute path of any `Container`, call
153157
* `Container.getAbsolutePath()` directly.
154158
*/
155-
override string toString() { result = getAbsolutePath() }
159+
override string toString() { result = this.getAbsolutePath() }
156160
}
157161

158162
/** A folder. */
159163
class Folder extends Container, @folder {
160164
override string getAbsolutePath() { folders(this, result) }
161165

162166
/** Gets the URL of this folder. */
163-
override string getURL() { result = "folder://" + getAbsolutePath() }
167+
override string getURL() { result = "folder://" + this.getAbsolutePath() }
164168

165169
override string getAPrimaryQlClass() { result = "Folder" }
166170
}
@@ -183,7 +187,7 @@ class File extends Container, @file {
183187
* A Java archive file with a ".jar" extension.
184188
*/
185189
class JarFile extends File {
186-
JarFile() { getExtension() = "jar" }
190+
JarFile() { this.getExtension() = "jar" }
187191

188192
/**
189193
* Gets the main attribute with the specified `key`
@@ -195,13 +199,17 @@ class JarFile extends File {
195199
* Gets the "Specification-Version" main attribute
196200
* from this JAR file's manifest.
197201
*/
198-
string getSpecificationVersion() { result = getManifestMainAttribute("Specification-Version") }
202+
string getSpecificationVersion() {
203+
result = this.getManifestMainAttribute("Specification-Version")
204+
}
199205

200206
/**
201207
* Gets the "Implementation-Version" main attribute
202208
* from this JAR file's manifest.
203209
*/
204-
string getImplementationVersion() { result = getManifestMainAttribute("Implementation-Version") }
210+
string getImplementationVersion() {
211+
result = this.getManifestMainAttribute("Implementation-Version")
212+
}
205213

206214
/**
207215
* Gets the per-entry attribute for the specified `entry` and `key`

java/ql/lib/semmle/code/Location.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ class Top extends @top {
6363
predicate hasLocationInfo(
6464
string filepath, int startline, int startcolumn, int endline, int endcolumn
6565
) {
66-
hasLocationInfoAux(filepath, startline, startcolumn, endline, endcolumn)
66+
this.hasLocationInfoAux(filepath, startline, startcolumn, endline, endcolumn)
6767
or
6868
exists(string outFilepath, int outStartline, int outEndline |
69-
hasLocationInfoAux(outFilepath, outStartline, _, outEndline, _) and
69+
this.hasLocationInfoAux(outFilepath, outStartline, _, outEndline, _) and
7070
hasSmapLocationInfo(filepath, startline, startcolumn, endline, endcolumn, outFilepath,
7171
outStartline, outEndline)
7272
)
@@ -103,7 +103,7 @@ class Top extends @top {
103103
/**
104104
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
105105
*/
106-
final string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
106+
final string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") }
107107

108108
/**
109109
* Gets the name of a primary CodeQL class to which this element belongs.

java/ql/lib/semmle/code/java/Annotation.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Annotation extends @annotation, Expr {
5151
Expr getValue(string name) { filteredAnnotValue(this, this.getAnnotationElement(name), result) }
5252

5353
/** Gets the element being annotated. */
54-
Element getTarget() { result = getAnnotatedElement() }
54+
Element getTarget() { result = this.getAnnotatedElement() }
5555

5656
override string toString() { result = this.getType().getName() }
5757

@@ -67,8 +67,8 @@ class Annotation extends @annotation, Expr {
6767
* expression defined for the value.
6868
*/
6969
Expr getAValue(string name) {
70-
getType().getAnnotationElement(name).getType() instanceof Array and
71-
exists(Expr value | value = getValue(name) |
70+
this.getType().getAnnotationElement(name).getType() instanceof Array and
71+
exists(Expr value | value = this.getValue(name) |
7272
if value instanceof ArrayInit then result = value.(ArrayInit).getAnInit() else result = value
7373
)
7474
}
@@ -104,7 +104,7 @@ class Annotatable extends Element {
104104

105105
/** Holds if this element has the specified annotation. */
106106
predicate hasAnnotation(string package, string name) {
107-
exists(AnnotationType at | at = getAnAnnotation().getType() |
107+
exists(AnnotationType at | at = this.getAnAnnotation().getType() |
108108
at.nestedName() = name and at.getPackage().getName() = package
109109
)
110110
}
@@ -118,7 +118,7 @@ class Annotatable extends Element {
118118
* annotation attached to it for the specified `category`.
119119
*/
120120
predicate suppressesWarningsAbout(string category) {
121-
category = getAnAnnotation().(SuppressWarningsAnnotation).getASuppressedWarning()
121+
category = this.getAnAnnotation().(SuppressWarningsAnnotation).getASuppressedWarning()
122122
or
123123
this.(Member).getDeclaringType().suppressesWarningsAbout(category)
124124
or

java/ql/lib/semmle/code/java/ControlFlowGraph.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,13 @@ private module ControlFlowGraphImpl {
528528

529529
/** Gets the first child node, if any. */
530530
ControlFlowNode firstChild() {
531-
result = getChildNode(-1)
531+
result = this.getChildNode(-1)
532532
or
533-
result = getChildNode(0) and not exists(getChildNode(-1))
533+
result = this.getChildNode(0) and not exists(this.getChildNode(-1))
534534
}
535535

536536
/** Holds if this CFG node has any child nodes. */
537-
predicate isLeafNode() { not exists(getChildNode(_)) }
537+
predicate isLeafNode() { not exists(this.getChildNode(_)) }
538538

539539
/** Holds if this node can finish with a `normalCompletion`. */
540540
predicate mayCompleteNormally() {
@@ -1222,10 +1222,10 @@ class ConditionNode extends ControlFlowNode {
12221222
ControlFlowNode getABranchSuccessor(boolean branch) { result = branchSuccessor(this, branch) }
12231223

12241224
/** Gets a true-successor of the `ConditionNode`. */
1225-
ControlFlowNode getATrueSuccessor() { result = getABranchSuccessor(true) }
1225+
ControlFlowNode getATrueSuccessor() { result = this.getABranchSuccessor(true) }
12261226

12271227
/** Gets a false-successor of the `ConditionNode`. */
1228-
ControlFlowNode getAFalseSuccessor() { result = getABranchSuccessor(false) }
1228+
ControlFlowNode getAFalseSuccessor() { result = this.getABranchSuccessor(false) }
12291229

12301230
/** Gets the condition of this `ConditionNode`. This is equal to the node itself. */
12311231
Expr getCondition() { result = this }

java/ql/lib/semmle/code/java/Conversions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract class ConversionSite extends Expr {
2727
/**
2828
* Whether this conversion site actually induces a conversion.
2929
*/
30-
predicate isTrivial() { getConversionTarget() = getConversionSource() }
30+
predicate isTrivial() { this.getConversionTarget() = this.getConversionSource() }
3131

3232
/**
3333
* Whether this conversion is implicit.

java/ql/lib/semmle/code/java/Element.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ class Element extends @element, Top {
3434
* Elements pertaining to source files may include generated elements
3535
* not visible in source code, such as implicit default constructors.
3636
*/
37-
predicate fromSource() { getCompilationUnit().getExtension() = "java" }
37+
predicate fromSource() { this.getCompilationUnit().getExtension() = "java" }
3838

3939
/** Gets the compilation unit that this element belongs to. */
40-
CompilationUnit getCompilationUnit() { result = getFile() }
40+
CompilationUnit getCompilationUnit() { result = this.getFile() }
4141

4242
/** Cast this element to a `Documentable`. */
4343
Documentable getDoc() { result = this }

0 commit comments

Comments
 (0)