mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Swift: add an internal query-suite for listing all the compiler errors
This commit is contained in:
@@ -1,5 +1,31 @@
|
||||
private import codeql.swift.generated.Diagnostics
|
||||
|
||||
class Diagnostics extends Generated::Diagnostics {
|
||||
override string toString() { result = getText() }
|
||||
override string toString() { result = getSeverity() + ": " + getText() }
|
||||
|
||||
string getSeverity() {
|
||||
getKind() = 1 and result = "error"
|
||||
or
|
||||
getKind() = 2 and result = "warning"
|
||||
or
|
||||
getKind() = 3 and result = "note"
|
||||
or
|
||||
getKind() = 4 and result = "remark"
|
||||
}
|
||||
}
|
||||
|
||||
class CompilerError extends Diagnostics {
|
||||
CompilerError() { this.getSeverity() = "error" }
|
||||
}
|
||||
|
||||
class CompilerWarning extends Diagnostics {
|
||||
CompilerWarning() { this.getSeverity() = "warning" }
|
||||
}
|
||||
|
||||
class CompilerNote extends Diagnostics {
|
||||
CompilerNote() { this.getSeverity() = "note" }
|
||||
}
|
||||
|
||||
class CompilerRemark extends Diagnostics {
|
||||
CompilerRemark() { this.getSeverity() = "remark" }
|
||||
}
|
||||
|
||||
11
swift/ql/src/diagnostics/internal/CompilerErrors.ql
Normal file
11
swift/ql/src/diagnostics/internal/CompilerErrors.ql
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @name Compiler errors
|
||||
* @description List all compiler errors for files in the source code directory.
|
||||
* @kind diagnostic
|
||||
* @id swift/diagnostics/compiler-errors
|
||||
*/
|
||||
|
||||
import swift
|
||||
|
||||
from CompilerError error
|
||||
select error, "Compiler error in " + error.getFile() + " with error message " + error.getText()
|
||||
@@ -1,3 +1,3 @@
|
||||
| diags.swift:1:10:1:10 | Hello, warning | getText: | Hello, warning | getKind: | 2 |
|
||||
| error.swift:2:14:2:14 | cannot convert value of type 'String' to specified type 'Int' | getText: | cannot convert value of type 'String' to specified type 'Int' | getKind: | 1 |
|
||||
| import-error.swift:2:8:2:8 | no such module 'FooBar' | getText: | no such module 'FooBar' | getKind: | 1 |
|
||||
| diags.swift:1:10:1:10 | warning: Hello, warning | getText: | Hello, warning | getKind: | 2 |
|
||||
| error.swift:2:14:2:14 | error: cannot convert value of type 'String' to specified type 'Int' | getText: | cannot convert value of type 'String' to specified type 'Int' | getKind: | 1 |
|
||||
| import-error.swift:2:8:2:8 | error: no such module 'FooBar' | getText: | no such module 'FooBar' | getKind: | 1 |
|
||||
|
||||
Reference in New Issue
Block a user