Simplify diagnostic query

This commit is contained in:
Benjamin Muskalla
2021-11-19 11:42:31 +01:00
parent fb9b16325d
commit cd39d15b40

View File

@@ -1,7 +1,6 @@
/**
* @name Framework coverage
* @description The number of API endpoints covered by CSV models sorted by
* package and source-, sink-, and summary-kind.
* @name Diagnostics for framework coverage
* @description Expose diagnostics for the number of API endpoints covered by CSV models.
* @kind diagnostic
* @id java/diagnostics/framework-coverage
*/
@@ -9,24 +8,11 @@
import java
import semmle.code.java.dataflow.ExternalFlow
string supportedPackageAndType() {
exists(string package, string type |
modelCoverage(package, _, _, type, _) and result = package + ";" + type
)
}
bindingset[packageAndType]
int rowsForPackageAndType(string packageAndType) {
result =
sum(int n, string package, string type |
package = packageAndType.substring(0, packageAndType.indexOf(";")) and
type = packageAndType.substring(packageAndType.indexOf(";") + 1, packageAndType.length()) and
modelCoverage(package, _, _, type, n)
|
n
)
}
from string packageAndType, int rows
where packageAndType = supportedPackageAndType() and rows = rowsForPackageAndType(packageAndType)
select packageAndType, rows order by rows desc
where
exists(string package, string type |
modelCoverage(package, _, _, type, _) and
packageAndType = package + ";" + type and
rows = sum(int n | modelCoverage(package, _, _, type, n) | n)
)
select packageAndType, rows