Skip to content

Commit 270e38d

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: add comments and switch getDeclaringType to getCompilationUnit
1 parent 6854845 commit 270e38d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private float getNumMadModeledApis(string package, string provenance) {
1919
provenance in ["generated", "manual", "both"] and
2020
result =
2121
count(SummarizedCallable sc |
22-
package = sc.asCallable().getDeclaringType().getPackage().toString() and
22+
package = sc.asCallable().getCompilationUnit().getPackage().getName() and
2323
exists(DataFlowTargetApi dataFlowTargApi | sc.asCallable() = dataFlowTargApi) and
2424
(
2525
sc.isAutoGenerated() and // "auto-only"
@@ -39,21 +39,26 @@ bindingset[package]
3939
private float getNumApis(string package) {
4040
result =
4141
count(DataFlowTargetApi dataFlowTargApi |
42-
package = dataFlowTargApi.getDeclaringType().getPackage().toString()
42+
package = dataFlowTargApi.getCompilationUnit().getPackage().getName()
4343
)
4444
}
4545

4646
from
4747
DataFlowTargetApi dataFlowTargApi, string package, float generatedOnly, float both,
4848
float manualOnly, float non, float all, float generatedCoverage, float manualCoverage
4949
where
50-
package = dataFlowTargApi.getDeclaringType().getPackage().toString() and
50+
// bind `package` to a `DataFlowTargetApi` package name
51+
package = dataFlowTargApi.getCompilationUnit().getPackage().getName() and
52+
// count the number of APIs with generated-only, both, and manual-only MaD models for each package
5153
generatedOnly = getNumMadModeledApis(package, "generated") and
52-
manualOnly = getNumMadModeledApis(package, "manual") and
5354
both = getNumMadModeledApis(package, "both") and
55+
manualOnly = getNumMadModeledApis(package, "manual") and
56+
// count the total number of `DataFlowTargetApi`s for each package
5457
all = getNumApis(package) and
5558
non = all - (generatedOnly + both + manualOnly) and
56-
generatedCoverage = (both / (both + manualOnly)) and // Proportion of manual models covered by generated ones
57-
manualCoverage = (both / (both + generatedOnly)) // Proportion of generated models covered by manual ones
59+
// Proportion of manual models covered by generated ones
60+
generatedCoverage = (both / (both + manualOnly)) and
61+
// Proportion of generated models covered by manual ones
62+
manualCoverage = (both / (both + generatedOnly))
5863
select package, generatedOnly, both, manualOnly, non, all, generatedCoverage, manualCoverage
5964
order by package

0 commit comments

Comments
 (0)