mirror of
https://github.com/github/codeql.git
synced 2025-12-24 12:46:34 +01:00
Avoid duplicates and support modular runtime
This commit is contained in:
@@ -23,6 +23,14 @@ class ExternalAPI extends Callable {
|
||||
}
|
||||
|
||||
predicate isSupported() { not supportKind(this) = "?" }
|
||||
|
||||
string jarContainer() {
|
||||
result = containerAsJar(any(ExternalAPI api).getCompilationUnit().getParentContainer*())
|
||||
}
|
||||
|
||||
private string containerAsJar(Container container) {
|
||||
if container instanceof JarFile then result = container.getBaseName() else result = "rt.jar"
|
||||
}
|
||||
}
|
||||
|
||||
private class TestLibrary extends RefType {
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
/**
|
||||
* @name External libraries
|
||||
* @description A list of external libraries used in the code
|
||||
* @kind diagnostic
|
||||
* @kind metric
|
||||
* @metricType callable
|
||||
* @id java/telemetry/external-libs
|
||||
*/
|
||||
|
||||
import java
|
||||
import ExternalAPI
|
||||
|
||||
from int Usages, JarFile jar
|
||||
from int Usages, string jarname
|
||||
where
|
||||
jar = any(ExternalAPI api).getCompilationUnit().getParentContainer*() and
|
||||
jarname = any(ExternalAPI api).jarContainer() and
|
||||
Usages =
|
||||
strictcount(Call c, ExternalAPI a |
|
||||
c.getCallee() = a and
|
||||
not c.getFile() instanceof GeneratedFile and
|
||||
a.getCompilationUnit().getParentContainer*() = jar and
|
||||
a.jarContainer() = jarname and
|
||||
not a.isTestLibrary()
|
||||
)
|
||||
select jar.getFile().getBaseName(), Usages order by Usages desc
|
||||
select jarname, Usages order by Usages desc
|
||||
|
||||
Reference in New Issue
Block a user