Skip to content

Commit 7e23bf3

Browse files
committed
Ruby: remove some redundant getASubclass() calls
1 parent b7c7449 commit 7e23bf3

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

ruby/ql/lib/codeql/ruby/frameworks/ActiveRecord.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private API::Node activeRecordClassApiNode() {
4040
// In Rails applications `ApplicationRecord` typically extends `ActiveRecord::Base`, but we
4141
// treat it separately in case the `ApplicationRecord` definition is not in the database.
4242
API::getTopLevelMember("ApplicationRecord")
43-
].getASubclass()
43+
]
4444
}
4545

4646
/**
@@ -58,7 +58,7 @@ private API::Node activeRecordClassApiNode() {
5858
class ActiveRecordModelClass extends ClassDeclaration {
5959
ActiveRecordModelClass() {
6060
this.getSuperclassExpr() =
61-
activeRecordClassApiNode().getAValueReachableFromSource().asExpr().getExpr()
61+
activeRecordClassApiNode().getASubclass().getAValueReachableFromSource().asExpr().getExpr()
6262
}
6363

6464
// Gets the class declaration for this class and all of its super classes

ruby/ql/lib/codeql/ruby/frameworks/ActiveResource.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ module ActiveResource {
1717
/**
1818
* An ActiveResource model class. This is any (transitive) subclass of ActiveResource.
1919
*/
20+
pragma[nomagic]
2021
private API::Node modelApiNode() {
21-
result = API::getTopLevelMember("ActiveResource").getMember("Base").getASubclass+()
22+
result = API::getTopLevelMember("ActiveResource").getMember("Base").getASubclass()
2223
}
2324

2425
/**

ruby/ql/lib/codeql/ruby/frameworks/ActiveStorage.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ module ActiveStorage {
8585
// Class methods
8686
API::getTopLevelMember("ActiveStorage")
8787
.getMember("Blob")
88-
.getASubclass()
8988
.getAMethodCall(["create_after_unfurling!", "create_and_upload!"]),
9089
// Instance methods
9190
any(BlobInstance i, DataFlow::CallNode c |

ruby/ql/lib/codeql/ruby/frameworks/GraphQL.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private class GraphqlRelayClassicMutationClass extends ClassDeclaration {
4242
this.getSuperclassExpr() =
4343
graphQlSchema()
4444
.getMember("RelayClassicMutation")
45-
.getASubclass*()
45+
.getASubclass()
4646
.getAValueReachableFromSource()
4747
.asExpr()
4848
.getExpr()

ruby/ql/lib/codeql/ruby/frameworks/Twirp.qll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ module Twirp {
1818
*/
1919
class ServiceInstantiation extends DataFlow::CallNode {
2020
ServiceInstantiation() {
21-
this =
22-
API::getTopLevelMember("Twirp").getMember("Service").getASubclass().getAnInstantiation()
21+
this = API::getTopLevelMember("Twirp").getMember("Service").getAnInstantiation()
2322
}
2423

2524
/**
@@ -62,7 +61,7 @@ module Twirp {
6261
*/
6362
class ClientInstantiation extends DataFlow::CallNode {
6463
ClientInstantiation() {
65-
this = API::getTopLevelMember("Twirp").getMember("Client").getASubclass().getAnInstantiation()
64+
this = API::getTopLevelMember("Twirp").getMember("Client").getAnInstantiation()
6665
}
6766
}
6867

0 commit comments

Comments
 (0)