mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
Merge pull request #13121 from kaspersv/kaspersv/javascript-explicit-this-receivers4
JS: Make implicit this receivers explicit
This commit is contained in:
@@ -10,10 +10,12 @@ module ESLint {
|
||||
*/
|
||||
abstract class Configuration extends Locatable {
|
||||
/** Gets the folder in which this configuration file is located. */
|
||||
private Folder getEnclosingFolder() { result = getFile().getParentContainer() }
|
||||
private Folder getEnclosingFolder() { result = this.getFile().getParentContainer() }
|
||||
|
||||
/** Holds if this configuration file applies to the code in `tl`. */
|
||||
predicate appliesTo(TopLevel tl) { tl.getFile().getParentContainer+() = getEnclosingFolder() }
|
||||
predicate appliesTo(TopLevel tl) {
|
||||
tl.getFile().getParentContainer+() = this.getEnclosingFolder()
|
||||
}
|
||||
|
||||
/** Gets the `globals` configuration object of this file, if any. */
|
||||
abstract ConfigurationObject getGlobals();
|
||||
@@ -39,11 +41,11 @@ module ESLint {
|
||||
/** An `.eslintrc.json` file. */
|
||||
private class EslintrcJson extends JsonConfiguration {
|
||||
EslintrcJson() {
|
||||
isTopLevel() and
|
||||
exists(string n | n = getFile().getBaseName() | n = ".eslintrc.json" or n = ".eslintrc")
|
||||
this.isTopLevel() and
|
||||
exists(string n | n = this.getFile().getBaseName() | n = ".eslintrc.json" or n = ".eslintrc")
|
||||
}
|
||||
|
||||
override ConfigurationObject getGlobals() { result = getPropValue("globals") }
|
||||
override ConfigurationObject getGlobals() { result = this.getPropValue("globals") }
|
||||
}
|
||||
|
||||
/** An ESLint configuration object in JSON format. */
|
||||
@@ -51,7 +53,7 @@ module ESLint {
|
||||
override Configuration getConfiguration() { this = result.(JsonConfiguration).getPropValue(_) }
|
||||
|
||||
override boolean getBooleanProperty(string p) {
|
||||
exists(string v | v = getPropValue(p).(JsonBoolean).getValue() |
|
||||
exists(string v | v = this.getPropValue(p).(JsonBoolean).getValue() |
|
||||
v = "true" and result = true
|
||||
or
|
||||
v = "false" and result = false
|
||||
@@ -62,7 +64,7 @@ module ESLint {
|
||||
/** An `.eslintrc.yaml` file. */
|
||||
private class EslintrcYaml extends Configuration instanceof YamlMapping, YamlDocument {
|
||||
EslintrcYaml() {
|
||||
exists(string n | n = getFile().getBaseName() |
|
||||
exists(string n | n = this.(Locatable).getFile().getBaseName() |
|
||||
n = ".eslintrc.yaml" or n = ".eslintrc.yml" or n = ".eslintrc"
|
||||
)
|
||||
}
|
||||
@@ -91,7 +93,7 @@ module ESLint {
|
||||
exists(PackageJson pkg | this = pkg.getPropValue("eslintConfig"))
|
||||
}
|
||||
|
||||
override ConfigurationObject getGlobals() { result = getPropValue("globals") }
|
||||
override ConfigurationObject getGlobals() { result = this.getPropValue("globals") }
|
||||
}
|
||||
|
||||
/** An ESLint `globals` configuration object. */
|
||||
@@ -99,10 +101,12 @@ module ESLint {
|
||||
GlobalsConfigurationObject() { this = any(Configuration cfg).getGlobals() }
|
||||
|
||||
override predicate declaresGlobal(string name, boolean writable) {
|
||||
getBooleanProperty(name) = writable
|
||||
this.getBooleanProperty(name) = writable
|
||||
}
|
||||
|
||||
override predicate appliesTo(ExprOrStmt s) { getConfiguration().appliesTo(s.getTopLevel()) }
|
||||
override predicate appliesTo(ExprOrStmt s) {
|
||||
this.getConfiguration().appliesTo(s.getTopLevel())
|
||||
}
|
||||
|
||||
abstract override Configuration getConfiguration();
|
||||
|
||||
|
||||
@@ -17,22 +17,22 @@ module ExtractionMetrics {
|
||||
/**
|
||||
* Gets the CPU time in nanoseconds it took to extract this file.
|
||||
*/
|
||||
float getCpuTime() { result = strictsum(getTime(_, 0)) }
|
||||
float getCpuTime() { result = strictsum(this.getTime(_, 0)) }
|
||||
|
||||
/**
|
||||
* Gets the wall-clock time in nanoseconds it took to extract this file.
|
||||
*/
|
||||
float getWallclockTime() { result = strictsum(getTime(_, 1)) }
|
||||
float getWallclockTime() { result = strictsum(this.getTime(_, 1)) }
|
||||
|
||||
/**
|
||||
* Gets the CPU time in nanoseconds it took to process phase `phaseName` during the extraction of this file.
|
||||
*/
|
||||
float getCpuTime(PhaseName phaseName) { result = getTime(phaseName, 0) }
|
||||
float getCpuTime(PhaseName phaseName) { result = this.getTime(phaseName, 0) }
|
||||
|
||||
/**
|
||||
* Gets the wall-clock time in nanoseconds it took to process phase `phaseName` during the extraction of this file.
|
||||
*/
|
||||
float getWallclockTime(PhaseName phaseName) { result = getTime(phaseName, 1) }
|
||||
float getWallclockTime(PhaseName phaseName) { result = this.getTime(phaseName, 1) }
|
||||
|
||||
/**
|
||||
* Holds if this file was extracted from the trap cache.
|
||||
@@ -60,7 +60,7 @@ module ExtractionMetrics {
|
||||
) = time
|
||||
|
|
||||
// assume the cache-lookup was for free
|
||||
if isFromCache() then result = 0 else result = time
|
||||
if this.isFromCache() then result = 0 else result = time
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user