Skip to content

Commit 2c3adb7

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: remove MadModeledCallable class and update predicate names
1 parent 974c000 commit 2c3adb7

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

java/ql/src/Metrics/Summaries/GeneratedVsManualCoverage.ql

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,24 @@ import semmle.code.java.dataflow.FlowSummary
1111
import utils.modelgenerator.internal.CaptureModels
1212

1313
/**
14-
* A callable with a Summary MaD model. Specifically, this callable is
15-
* the intersection of DataFlowTargetApis and SummarizedCallables.
14+
* Returns the number of `DataFlowTargetApi`s with Summary MaD models
15+
* for a given package and provenance.
1616
*/
17-
private class MadModeledCallable extends SummarizedCallableBase {
18-
MadModeledCallable() {
19-
this instanceof SummarizedCallable and
20-
exists(DataFlowTargetApi dataFlowTargApi | this.asCallable() = dataFlowTargApi)
21-
}
22-
}
23-
24-
/** Returns the number of APIs with Summary MaD models for a given package and provenance. */
2517
bindingset[package]
26-
private float getNumApisWithMadModels(string package, string provenance) {
18+
private float getNumMadModeledApis(string package, string provenance) {
2719
provenance in ["generated", "manual", "both"] and
2820
result =
29-
count(MadModeledCallable mc |
30-
package = mc.asCallable().getDeclaringType().getPackage().toString() and
21+
count(SummarizedCallable sc |
22+
package = sc.asCallable().getDeclaringType().getPackage().toString() and
23+
exists(DataFlowTargetApi dataFlowTargApi | sc.asCallable() = dataFlowTargApi) and
3124
(
32-
mc.(SummarizedCallable).isAutoGenerated() and // "auto-only"
25+
sc.isAutoGenerated() and // "auto-only"
3326
provenance = "generated"
3427
or
35-
mc.(SummarizedCallable).isManuallyGenerated() and // "manual-only"
28+
sc.isManuallyGenerated() and // "manual-only"
3629
provenance = "manual"
3730
or
38-
mc.(SummarizedCallable).isBothAutoAndManuallyGenerated() and // "both"
31+
sc.isBothAutoAndManuallyGenerated() and // "both"
3932
provenance = "both"
4033
)
4134
)
@@ -55,9 +48,9 @@ from
5548
float manualOnly, float non, float all, float generatedCoverage, float manualCoverage
5649
where
5750
package = dataFlowTargApi.getDeclaringType().getPackage().toString() and
58-
generatedOnly = getNumApisWithMadModels(package, "generated") and
59-
manualOnly = getNumApisWithMadModels(package, "manual") and
60-
both = getNumApisWithMadModels(package, "both") and
51+
generatedOnly = getNumMadModeledApis(package, "generated") and
52+
manualOnly = getNumMadModeledApis(package, "manual") and
53+
both = getNumMadModeledApis(package, "both") and
6154
all = getNumApis(package) and
6255
non = all - (generatedOnly + both + manualOnly) and
6356
generatedCoverage = (both / (both + manualOnly)) and // Proportion of manual models covered by generated ones

0 commit comments

Comments
 (0)