Skip to content

Commit d288b3d

Browse files
committed
C#: Refactor and narrow number of displayed results of the External library usage query.
1 parent 51d2eb6 commit d288b3d

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

csharp/ql/src/Telemetry/ExternalLibraryUsage.ql

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,28 @@ private import csharp
1010
private import semmle.code.csharp.dispatch.Dispatch
1111
private import ExternalApi
1212

13-
from int usages, string info
14-
where
13+
private predicate getRelevantUsages(string info, int usages) {
1514
usages =
1615
strictcount(DispatchCall c, ExternalApi api |
1716
c = api.getACall() and
1817
api.getInfoPrefix() = info and
1918
not api.isUninteresting()
2019
)
20+
}
21+
22+
private int getOrder(string info) {
23+
info =
24+
rank[result](string i, int usages |
25+
exists(ExternalApi api | i = api.getInfoPrefix()) and
26+
getRelevantUsages(i, usages)
27+
|
28+
i order by usages desc, i
29+
)
30+
}
31+
32+
from ExternalApi api, string info, int usages
33+
where
34+
info = api.getInfoPrefix() and
35+
getRelevantUsages(info, usages) and
36+
getOrder(info) <= resultLimit()
2137
select info, usages order by usages desc

0 commit comments

Comments
 (0)