Skip to content

Commit 8853489

Browse files
committed
Kotlin: Add a "generted by" field to the diagnostics table
1 parent 512e4ce commit 8853489

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

java/kotlin-extractor/src/main/kotlin/utils/Logger.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ open class Logger(val logCounter: LogCounter, open val tw: TrapWriter) {
8484
}
8585
}
8686
val ts = timestamp()
87-
tw.writeDiagnostics(StarLabel(), severity.sev, "", msg, "$ts $msg\n$suffix", locationId)
87+
tw.writeDiagnostics(StarLabel(), "CodeQL Kotlin extractor", severity.sev, "", msg, "$ts $msg\n$suffix", locationId)
8888
val locStr = if (locationString == null) "" else "At " + locationString + ": "
8989
print("$ts Warning($warningLocStr): $locStr$msg\n$suffix")
9090
}

java/ql/consistency-queries/locations.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Location unusedLocation() {
2020
not exists(Top t | t.getLocation() = result) and
2121
not exists(XMLLocatable x | x.getLocation() = result) and
2222
not exists(ConfigLocatable c | c.getLocation() = result) and
23-
not exists(@diagnostic d | diagnostics(d, _, _, _, _, result)) and
23+
not exists(@diagnostic d | diagnostics(d, _, _, _, _, _, result)) and
2424
not (result.getFile().getExtension() = "xml" and
2525
result.getStartLine() = 0 and
2626
result.getStartColumn() = 0 and

java/ql/lib/config/semmlecode.dbscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ compilation_finished(
140140

141141
diagnostics(
142142
unique int id: @diagnostic,
143+
string generated_by: string ref, // TODO: Sync this with CPP?
143144
int severity: int ref,
144145
string error_tag: string ref,
145146
string error_message: string ref,

java/ql/src/Diagnostics/DiagnosticsReporting.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ private int getWarnSeverity() { result = 1 }
1212

1313
private predicate knownWarnings(@diagnostic d, string msg, int sev) {
1414
exists(string filename |
15-
diagnostics(d, 2, _, "Skipping Lombok-ed source file: " + filename, _, _) and
15+
diagnostics(d, _, 2, _, "Skipping Lombok-ed source file: " + filename, _, _) and
1616
msg = "Use of Lombok detected. Skipping file: " + filename and
1717
sev = getWarnSeverity()
1818
)
1919
}
2020

2121
private predicate knownErrors(@diagnostic d, string msg, int sev) {
2222
exists(string numErr, Location l |
23-
diagnostics(d, 6, _, numErr, _, l) and
23+
diagnostics(d, _, 6, _, numErr, _, l) and
2424
msg = "Frontend errors in file: " + l.getFile().getAbsolutePath() + " (" + numErr + ")" and
2525
sev = getErrorSeverity()
2626
)
2727
or
2828
exists(string filename, Location l |
29-
diagnostics(d, 7, _, "Exception compiling file " + filename, _, l) and
29+
diagnostics(d, _, 7, _, "Exception compiling file " + filename, _, l) and
3030
msg = "Extraction incomplete in file: " + filename and
3131
sev = getErrorSeverity()
3232
)
3333
or
3434
exists(string errMsg, Location l |
35-
diagnostics(d, 8, _, errMsg, _, l) and
35+
diagnostics(d, _, 8, _, errMsg, _, l) and
3636
msg = "Severe error: " + errMsg and
3737
sev = getErrorSeverity()
3838
)
@@ -41,7 +41,7 @@ private predicate knownErrors(@diagnostic d, string msg, int sev) {
4141
private predicate unknownErrors(@diagnostic d, string msg, int sev) {
4242
not knownErrors(d, _, _) and
4343
exists(Location l, File f, int diagSev |
44-
diagnostics(d, diagSev, _, _, _, l) and l.getFile() = f and diagSev > 3
44+
diagnostics(d, _, diagSev, _, _, _, l) and l.getFile() = f and diagSev > 3
4545
|
4646
exists(f.getRelativePath()) and
4747
msg = "Unknown errors in file: " + f.getAbsolutePath() + " (" + diagSev + ")" and
@@ -77,7 +77,7 @@ predicate reportableWarnings(@diagnostic d, string msg, int sev) { knownWarnings
7777
*/
7878
predicate successfullyExtracted(CompilationUnit f) {
7979
not exists(@diagnostic d, Location l |
80-
reportableDiagnostics(d, _, _) and diagnostics(d, _, _, _, _, l) and l.getFile() = f
80+
reportableDiagnostics(d, _, _) and diagnostics(d, _, _, _, _, _, l) and l.getFile() = f
8181
) and
8282
exists(f.getRelativePath()) and
8383
f.fromSource()

0 commit comments

Comments
 (0)