Skip to content

Commit 31a1667

Browse files
committed
Java/Kotlin: Add ExtractorInformation query
1 parent c842677 commit 31a1667

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* @name Java extraction information
3+
* @description Information about the extraction for a Java database
4+
* @kind metric
5+
* @tags summary telemetry
6+
* @id java/telemetry/extraction-information
7+
*/
8+
9+
import java
10+
import semmle.code.java.Diagnostics
11+
12+
predicate fileCount(string key, int value) {
13+
key = "Number of files" and
14+
value = strictcount(File f)
15+
}
16+
17+
predicate fileCountByExtension(string key, int value) {
18+
exists(string extension |
19+
key = "Number of files with extension " + extension and
20+
value = strictcount(File f | f.getExtension() = extension)
21+
)
22+
}
23+
24+
predicate totalNumberOfLines(string key, int value) {
25+
key = "Total number of lines" and
26+
value = strictsum(File f | any() | f.getTotalNumberOfLines())
27+
}
28+
29+
predicate numberOfLinesOfCode(string key, int value) {
30+
key = "Number of lines of code" and
31+
value = strictsum(File f | any() | f.getNumberOfLinesOfCode())
32+
}
33+
34+
predicate totalNumberOfLinesByExtension(string key, int value) {
35+
exists(string extension |
36+
key = "Total number of lines with extension " + extension and
37+
value = strictsum(File f | f.getExtension() = extension | f.getTotalNumberOfLines())
38+
)
39+
}
40+
41+
predicate numberOfLinesOfCodeByExtension(string key, int value) {
42+
exists(string extension |
43+
key = "Number of lines of code with extension " + extension and
44+
value = strictsum(File f | f.getExtension() = extension | f.getNumberOfLinesOfCode())
45+
)
46+
}
47+
48+
predicate extractorDiagnostics(string key, int value) {
49+
exists(string extractor, int severity |
50+
key = "Number of diagnostics from " + extractor + " with severity " + severity.toString() and
51+
value =
52+
strictcount(Diagnostic d | d.getGeneratedBy() = extractor and d.getSeverity() = severity)
53+
)
54+
}
55+
56+
from string key, int value
57+
where
58+
fileCount(key, value) or
59+
fileCountByExtension(key, value) or
60+
totalNumberOfLines(key, value) or
61+
numberOfLinesOfCode(key, value) or
62+
totalNumberOfLinesByExtension(key, value) or
63+
numberOfLinesOfCodeByExtension(key, value) or
64+
extractorDiagnostics(key, value)
65+
select key, value

0 commit comments

Comments
 (0)