Ruby: remove some redundant getASubclass() calls

This commit is contained in:
Asger F
2023-04-11 15:16:55 +02:00
parent b7c7449b08
commit 7e23bf3938
5 changed files with 7 additions and 8 deletions

View File

@@ -40,7 +40,7 @@ private API::Node activeRecordClassApiNode() {
// In Rails applications `ApplicationRecord` typically extends `ActiveRecord::Base`, but we
// treat it separately in case the `ApplicationRecord` definition is not in the database.
API::getTopLevelMember("ApplicationRecord")
].getASubclass()
]
}
/**
@@ -58,7 +58,7 @@ private API::Node activeRecordClassApiNode() {
class ActiveRecordModelClass extends ClassDeclaration {
ActiveRecordModelClass() {
this.getSuperclassExpr() =
activeRecordClassApiNode().getAValueReachableFromSource().asExpr().getExpr()
activeRecordClassApiNode().getASubclass().getAValueReachableFromSource().asExpr().getExpr()
}
// Gets the class declaration for this class and all of its super classes

View File

@@ -17,8 +17,9 @@ module ActiveResource {
/**
* An ActiveResource model class. This is any (transitive) subclass of ActiveResource.
*/
pragma[nomagic]
private API::Node modelApiNode() {
result = API::getTopLevelMember("ActiveResource").getMember("Base").getASubclass+()
result = API::getTopLevelMember("ActiveResource").getMember("Base").getASubclass()
}
/**

View File

@@ -85,7 +85,6 @@ module ActiveStorage {
// Class methods
API::getTopLevelMember("ActiveStorage")
.getMember("Blob")
.getASubclass()
.getAMethodCall(["create_after_unfurling!", "create_and_upload!"]),
// Instance methods
any(BlobInstance i, DataFlow::CallNode c |

View File

@@ -42,7 +42,7 @@ private class GraphqlRelayClassicMutationClass extends ClassDeclaration {
this.getSuperclassExpr() =
graphQlSchema()
.getMember("RelayClassicMutation")
.getASubclass*()
.getASubclass()
.getAValueReachableFromSource()
.asExpr()
.getExpr()

View File

@@ -18,8 +18,7 @@ module Twirp {
*/
class ServiceInstantiation extends DataFlow::CallNode {
ServiceInstantiation() {
this =
API::getTopLevelMember("Twirp").getMember("Service").getASubclass().getAnInstantiation()
this = API::getTopLevelMember("Twirp").getMember("Service").getAnInstantiation()
}
/**
@@ -62,7 +61,7 @@ module Twirp {
*/
class ClientInstantiation extends DataFlow::CallNode {
ClientInstantiation() {
this = API::getTopLevelMember("Twirp").getMember("Client").getASubclass().getAnInstantiation()
this = API::getTopLevelMember("Twirp").getMember("Client").getAnInstantiation()
}
}