Skip to content

Commit fb9b163

Browse files
author
Benjamin Muskalla
committed
Add diagnostic query for framework coverage
1 parent 6f24947 commit fb9b163

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @name Framework coverage
3+
* @description The number of API endpoints covered by CSV models sorted by
4+
* package and source-, sink-, and summary-kind.
5+
* @kind diagnostic
6+
* @id java/diagnostics/framework-coverage
7+
*/
8+
9+
import java
10+
import semmle.code.java.dataflow.ExternalFlow
11+
12+
string supportedPackageAndType() {
13+
exists(string package, string type |
14+
modelCoverage(package, _, _, type, _) and result = package + ";" + type
15+
)
16+
}
17+
18+
bindingset[packageAndType]
19+
int rowsForPackageAndType(string packageAndType) {
20+
result =
21+
sum(int n, string package, string type |
22+
package = packageAndType.substring(0, packageAndType.indexOf(";")) and
23+
type = packageAndType.substring(packageAndType.indexOf(";") + 1, packageAndType.length()) and
24+
modelCoverage(package, _, _, type, n)
25+
|
26+
n
27+
)
28+
}
29+
30+
from string packageAndType, int rows
31+
where packageAndType = supportedPackageAndType() and rows = rowsForPackageAndType(packageAndType)
32+
select packageAndType, rows order by rows desc

0 commit comments

Comments
 (0)