mirror of
https://github.com/github/codeql.git
synced 2026-04-18 21:44:02 +02:00
C#: Refactor and narrow number of displayed results of the External library usage query.
This commit is contained in:
@@ -10,12 +10,28 @@ private import csharp
|
||||
private import semmle.code.csharp.dispatch.Dispatch
|
||||
private import ExternalApi
|
||||
|
||||
from int usages, string info
|
||||
where
|
||||
private predicate getRelevantUsages(string info, int usages) {
|
||||
usages =
|
||||
strictcount(DispatchCall c, ExternalApi api |
|
||||
c = api.getACall() and
|
||||
api.getInfoPrefix() = info and
|
||||
not api.isUninteresting()
|
||||
)
|
||||
}
|
||||
|
||||
private int getOrder(string info) {
|
||||
info =
|
||||
rank[result](string i, int usages |
|
||||
exists(ExternalApi api | i = api.getInfoPrefix()) and
|
||||
getRelevantUsages(i, usages)
|
||||
|
|
||||
i order by usages desc, i
|
||||
)
|
||||
}
|
||||
|
||||
from ExternalApi api, string info, int usages
|
||||
where
|
||||
info = api.getInfoPrefix() and
|
||||
getRelevantUsages(info, usages) and
|
||||
getOrder(info) <= resultLimit()
|
||||
select info, usages order by usages desc
|
||||
|
||||
Reference in New Issue
Block a user