mirror of
https://github.com/github/codeql.git
synced 2026-04-22 15:25:18 +02:00
Use predicate for isConstructor
This commit is contained in:
@@ -69,10 +69,10 @@ class MethodEndpoint extends Endpoint instanceof DataFlow::MethodNode {
|
||||
DataFlow::MethodNode getNode() { result = this }
|
||||
|
||||
override string getName() {
|
||||
result = super.getMethodName() and this.isConstructor() = false
|
||||
result = super.getMethodName() and not this.isConstructor()
|
||||
or
|
||||
// Constructors are modeled as Type!#new rather than Type#initialize
|
||||
result = "new" and this.isConstructor() = true
|
||||
result = "new" and this.isConstructor()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,13 +81,13 @@ class MethodEndpoint extends Endpoint instanceof DataFlow::MethodNode {
|
||||
override string getType() {
|
||||
result =
|
||||
any(DataFlow::ModuleNode m | m.getOwnInstanceMethod(this.getName()) = this).getQualifiedName() and
|
||||
this.isConstructor() = false
|
||||
not this.isConstructor()
|
||||
or
|
||||
// Constructors are modeled on `Type!`, not on `Type`
|
||||
result =
|
||||
any(DataFlow::ModuleNode m | m.getOwnInstanceMethod(super.getMethodName()) = this)
|
||||
.getQualifiedName() + "!" and
|
||||
this.isConstructor() = true
|
||||
this.isConstructor()
|
||||
or
|
||||
result =
|
||||
any(DataFlow::ModuleNode m | m.getOwnSingletonMethod(this.getName()) = this)
|
||||
@@ -158,12 +158,9 @@ class MethodEndpoint extends Endpoint instanceof DataFlow::MethodNode {
|
||||
/**
|
||||
* Holds if this method is a constructor for a module.
|
||||
*/
|
||||
private boolean isConstructor() {
|
||||
if
|
||||
super.getMethodName() = "initialize" and
|
||||
exists(DataFlow::ModuleNode m | m.getOwnInstanceMethod(super.getMethodName()) = this)
|
||||
then result = true
|
||||
else result = false
|
||||
private predicate isConstructor() {
|
||||
super.getMethodName() = "initialize" and
|
||||
exists(DataFlow::ModuleNode m | m.getOwnInstanceMethod(super.getMethodName()) = this)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user