Java: Manual rewrite of the ExternalLibraryUsage query to limit the number of returned results.

This commit is contained in:
Michael Nebel
2022-06-15 11:10:05 +02:00
parent b9b4aedd03
commit f810858ae4

View File

@@ -9,8 +9,7 @@
import java
import ExternalApi
from int usages, string jarname
where
private predicate getRelevantUsages(string jarname, int usages) {
usages =
strictcount(Call c, ExternalApi a |
c.getCallee().getSourceDeclaration() = a and
@@ -18,4 +17,20 @@ where
a.jarContainer() = jarname and
not a.isUninteresting()
)
}
private int getOrder(string jarname) {
jarname =
rank[result](string jar, int usages |
exists(ExternalApi api | jar = api.jarContainer()) and getRelevantUsages(jar, usages)
|
jar order by usages desc, jar
)
}
from ExternalApi api, string jarname, int usages
where
jarname = api.jarContainer() and
getRelevantUsages(jarname, usages) and
getOrder(jarname) <= resultLimit()
select jarname, usages order by usages desc