Skip to content

Commit d5f0a5c

Browse files
committed
Use predicate for isConstructor
1 parent c1aaf5a commit d5f0a5c

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

ruby/ql/src/utils/modeleditor/ModelEditor.qll

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ class MethodEndpoint extends Endpoint instanceof DataFlow::MethodNode {
6969
DataFlow::MethodNode getNode() { result = this }
7070

7171
override string getName() {
72-
result = super.getMethodName() and this.isConstructor() = false
72+
result = super.getMethodName() and not this.isConstructor()
7373
or
7474
// Constructors are modeled as Type!#new rather than Type#initialize
75-
result = "new" and this.isConstructor() = true
75+
result = "new" and this.isConstructor()
7676
}
7777

7878
/**
@@ -81,13 +81,13 @@ class MethodEndpoint extends Endpoint instanceof DataFlow::MethodNode {
8181
override string getType() {
8282
result =
8383
any(DataFlow::ModuleNode m | m.getOwnInstanceMethod(this.getName()) = this).getQualifiedName() and
84-
this.isConstructor() = false
84+
not this.isConstructor()
8585
or
8686
// Constructors are modeled on `Type!`, not on `Type`
8787
result =
8888
any(DataFlow::ModuleNode m | m.getOwnInstanceMethod(super.getMethodName()) = this)
8989
.getQualifiedName() + "!" and
90-
this.isConstructor() = true
90+
this.isConstructor()
9191
or
9292
result =
9393
any(DataFlow::ModuleNode m | m.getOwnSingletonMethod(this.getName()) = this)
@@ -158,12 +158,9 @@ class MethodEndpoint extends Endpoint instanceof DataFlow::MethodNode {
158158
/**
159159
* Holds if this method is a constructor for a module.
160160
*/
161-
private boolean isConstructor() {
162-
if
163-
super.getMethodName() = "initialize" and
164-
exists(DataFlow::ModuleNode m | m.getOwnInstanceMethod(super.getMethodName()) = this)
165-
then result = true
166-
else result = false
161+
private predicate isConstructor() {
162+
super.getMethodName() = "initialize" and
163+
exists(DataFlow::ModuleNode m | m.getOwnInstanceMethod(super.getMethodName()) = this)
167164
}
168165
}
169166

0 commit comments

Comments
 (0)