Skip to content

Commit ca00e0a

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: adjust none and all calculations
1 parent 6248efd commit ca00e0a

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

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

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//import java // not needed I guess
1010
import semmle.code.java.dataflow.FlowSummary // for SummarizedCallable
1111
import utils.modelgenerator.internal.CaptureModels // for DataFlowTargetApi
12+
import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl // for NegativeSummarizedCallable
1213

1314
// ! improve QLDoc?
1415
/**
@@ -53,8 +54,8 @@ float getNumMadModels(string package, string provenance) {
5354

5455
// ! move to other file
5556
/**
56-
* Returns the number of APIs without MaD
57-
* models for a given package.
57+
* Returns the number of APIs without SummarizedCallables
58+
* (MaD models) for a given package.
5859
*/
5960
float getNumApisWithoutMadModel(string package) {
6061
exists(DataFlowTargetApi dataFlowTargApi |
@@ -63,21 +64,40 @@ float getNumApisWithoutMadModel(string package) {
6364
result =
6465
count(DataFlowTargetApi d |
6566
package = d.getDeclaringType().getPackage().toString() and
66-
not exists(SummarizedCallable sc | d = sc.asCallable())
67+
not exists(MadModeledCallable sc | d = sc.asCallable())
6768
)
6869
)
6970
}
7071

72+
/**
73+
* Returns the total number of APIs for a given package.
74+
*/
75+
float getNumApis(string package) {
76+
exists(DataFlowTargetApi dataFlowTargApi |
77+
package = dataFlowTargApi.getDeclaringType().getPackage().toString()
78+
|
79+
result = count(DataFlowTargetApi d | package = d.getDeclaringType().getPackage().toString())
80+
)
81+
}
82+
7183
from
7284
string package, float generatedOnly, float both, float manualOnly, float non, float all,
7385
float generatedCoverage, float manualCoverage
7486
where
7587
generatedOnly = getNumMadModels(package, "generated") and
7688
manualOnly = getNumMadModels(package, "manual") and
7789
both = getNumMadModels(package, "both") and
78-
non = getNumApisWithoutMadModel(package) and // ! edit this
79-
all = generatedOnly + both + manualOnly + non and
90+
// non = getNumApisWithoutMadModel(package) and
91+
// all = generatedOnly + both + manualOnly + non and
92+
all = getNumApis(package) and
93+
non = all - (generatedOnly + both + manualOnly) and
8094
generatedCoverage = (both / (both + manualOnly)) and // Proportion of manual models covered by generated ones
8195
manualCoverage = (both / (both + generatedOnly)) // Proportion of generated models covered by manual ones
8296
select package, generatedOnly, both, manualOnly, non, all, generatedCoverage, manualCoverage
8397
order by package
98+
// * "all" and "none" tests
99+
// from string package, float num
100+
// where num = getNumApis(package) // allY2 = DFTAs
101+
// // where num = getNumModeledApis(package) // allY1 = api that has either a positive or negative model
102+
// // where num = getNumApisWithoutMadModel(package) // noneY2 = DFTAs \ SCs
103+
// select package, num order by package

0 commit comments

Comments
 (0)