From cd39d15b40bf0e45972bdb5ddb7b5a210de5e67e Mon Sep 17 00:00:00 2001 From: Benjamin Muskalla Date: Fri, 19 Nov 2021 11:42:31 +0100 Subject: [PATCH] Simplify diagnostic query --- .../ql/src/Diagnostics/CoverageDiagnostics.ql | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/java/ql/src/Diagnostics/CoverageDiagnostics.ql b/java/ql/src/Diagnostics/CoverageDiagnostics.ql index 5d1557a460d..6ccb2628893 100644 --- a/java/ql/src/Diagnostics/CoverageDiagnostics.ql +++ b/java/ql/src/Diagnostics/CoverageDiagnostics.ql @@ -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