Skip to content

Commit 2184fef

Browse files
authored
Merge pull request github#13121 from kaspersv/kaspersv/javascript-explicit-this-receivers4
JS: Make implicit this receivers explicit
2 parents ee64ea5 + 489a73c commit 2184fef

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

javascript/ql/lib/semmle/javascript/linters/ESLint.qll

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ module ESLint {
1010
*/
1111
abstract class Configuration extends Locatable {
1212
/** Gets the folder in which this configuration file is located. */
13-
private Folder getEnclosingFolder() { result = getFile().getParentContainer() }
13+
private Folder getEnclosingFolder() { result = this.getFile().getParentContainer() }
1414

1515
/** Holds if this configuration file applies to the code in `tl`. */
16-
predicate appliesTo(TopLevel tl) { tl.getFile().getParentContainer+() = getEnclosingFolder() }
16+
predicate appliesTo(TopLevel tl) {
17+
tl.getFile().getParentContainer+() = this.getEnclosingFolder()
18+
}
1719

1820
/** Gets the `globals` configuration object of this file, if any. */
1921
abstract ConfigurationObject getGlobals();
@@ -39,19 +41,19 @@ module ESLint {
3941
/** An `.eslintrc.json` file. */
4042
private class EslintrcJson extends JsonConfiguration {
4143
EslintrcJson() {
42-
isTopLevel() and
43-
exists(string n | n = getFile().getBaseName() | n = ".eslintrc.json" or n = ".eslintrc")
44+
this.isTopLevel() and
45+
exists(string n | n = this.getFile().getBaseName() | n = ".eslintrc.json" or n = ".eslintrc")
4446
}
4547

46-
override ConfigurationObject getGlobals() { result = getPropValue("globals") }
48+
override ConfigurationObject getGlobals() { result = this.getPropValue("globals") }
4749
}
4850

4951
/** An ESLint configuration object in JSON format. */
5052
private class JsonConfigurationObject extends ConfigurationObject, JsonObject {
5153
override Configuration getConfiguration() { this = result.(JsonConfiguration).getPropValue(_) }
5254

5355
override boolean getBooleanProperty(string p) {
54-
exists(string v | v = getPropValue(p).(JsonBoolean).getValue() |
56+
exists(string v | v = this.getPropValue(p).(JsonBoolean).getValue() |
5557
v = "true" and result = true
5658
or
5759
v = "false" and result = false
@@ -62,7 +64,7 @@ module ESLint {
6264
/** An `.eslintrc.yaml` file. */
6365
private class EslintrcYaml extends Configuration instanceof YamlMapping, YamlDocument {
6466
EslintrcYaml() {
65-
exists(string n | n = getFile().getBaseName() |
67+
exists(string n | n = this.(Locatable).getFile().getBaseName() |
6668
n = ".eslintrc.yaml" or n = ".eslintrc.yml" or n = ".eslintrc"
6769
)
6870
}
@@ -91,18 +93,20 @@ module ESLint {
9193
exists(PackageJson pkg | this = pkg.getPropValue("eslintConfig"))
9294
}
9395

94-
override ConfigurationObject getGlobals() { result = getPropValue("globals") }
96+
override ConfigurationObject getGlobals() { result = this.getPropValue("globals") }
9597
}
9698

9799
/** An ESLint `globals` configuration object. */
98100
class GlobalsConfigurationObject extends Linting::GlobalDeclaration, ConfigurationObject {
99101
GlobalsConfigurationObject() { this = any(Configuration cfg).getGlobals() }
100102

101103
override predicate declaresGlobal(string name, boolean writable) {
102-
getBooleanProperty(name) = writable
104+
this.getBooleanProperty(name) = writable
103105
}
104106

105-
override predicate appliesTo(ExprOrStmt s) { getConfiguration().appliesTo(s.getTopLevel()) }
107+
override predicate appliesTo(ExprOrStmt s) {
108+
this.getConfiguration().appliesTo(s.getTopLevel())
109+
}
106110

107111
abstract override Configuration getConfiguration();
108112

javascript/ql/lib/semmle/javascript/meta/ExtractionMetrics.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ module ExtractionMetrics {
1717
/**
1818
* Gets the CPU time in nanoseconds it took to extract this file.
1919
*/
20-
float getCpuTime() { result = strictsum(getTime(_, 0)) }
20+
float getCpuTime() { result = strictsum(this.getTime(_, 0)) }
2121

2222
/**
2323
* Gets the wall-clock time in nanoseconds it took to extract this file.
2424
*/
25-
float getWallclockTime() { result = strictsum(getTime(_, 1)) }
25+
float getWallclockTime() { result = strictsum(this.getTime(_, 1)) }
2626

2727
/**
2828
* Gets the CPU time in nanoseconds it took to process phase `phaseName` during the extraction of this file.
2929
*/
30-
float getCpuTime(PhaseName phaseName) { result = getTime(phaseName, 0) }
30+
float getCpuTime(PhaseName phaseName) { result = this.getTime(phaseName, 0) }
3131

3232
/**
3333
* Gets the wall-clock time in nanoseconds it took to process phase `phaseName` during the extraction of this file.
3434
*/
35-
float getWallclockTime(PhaseName phaseName) { result = getTime(phaseName, 1) }
35+
float getWallclockTime(PhaseName phaseName) { result = this.getTime(phaseName, 1) }
3636

3737
/**
3838
* Holds if this file was extracted from the trap cache.
@@ -60,7 +60,7 @@ module ExtractionMetrics {
6060
) = time
6161
|
6262
// assume the cache-lookup was for free
63-
if isFromCache() then result = 0 else result = time
63+
if this.isFromCache() then result = 0 else result = time
6464
)
6565
}
6666
}

0 commit comments

Comments
 (0)