mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Include compilation errors in diagnostic check
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
/**
|
||||
* @name Extraction errors
|
||||
* @description List all errors reported by the extractor. The returned issues are
|
||||
* limited to those files where there are no compilation errors. This
|
||||
* indicates a bug or limitation in the extractor, and could lead to
|
||||
* inaccurate results.
|
||||
* @description List all errors reported by the extractor or the compiler. Extractor errors are
|
||||
* limited to those files where there are no compilation errors.
|
||||
* @kind diagnostic
|
||||
* @id cs/diagnostics/extraction-errors
|
||||
*/
|
||||
@@ -11,13 +9,47 @@
|
||||
import csharp
|
||||
import semmle.code.csharp.commons.Diagnostics
|
||||
|
||||
private string getLocation(ExtractorError error) {
|
||||
if error.getLocation().getFile().fromSource()
|
||||
then result = " in " + error.getLocation().getFile()
|
||||
else result = ""
|
||||
private newtype TDiagnosticError =
|
||||
TCompilerError(CompilerError c) or
|
||||
TExtractorError(ExtractorError e)
|
||||
|
||||
abstract private class DiagnosticError extends TDiagnosticError {
|
||||
string getMessage() { none() }
|
||||
|
||||
string toString() { none() }
|
||||
|
||||
string getLocation(Location l) {
|
||||
if l.getFile().fromSource() then result = " in " + l.getFile() else result = ""
|
||||
}
|
||||
}
|
||||
|
||||
from ExtractorError error
|
||||
where not exists(CompilerError ce | ce.getLocation().getFile() = error.getLocation().getFile())
|
||||
select error,
|
||||
"Unexpected " + error.getOrigin() + " error" + getLocation(error) + ": " + error.getText(), 3
|
||||
private class DiagnosticCompilerError extends DiagnosticError {
|
||||
CompilerError c;
|
||||
|
||||
DiagnosticCompilerError() { this = TCompilerError(c) }
|
||||
|
||||
override string getMessage() {
|
||||
result = "Compiler error" + getLocation(c.getLocation()) + ": " + c.getMessage()
|
||||
}
|
||||
|
||||
override string toString() { result = c.toString() }
|
||||
}
|
||||
|
||||
private class DiagnosticExtractorError extends DiagnosticError {
|
||||
ExtractorError e;
|
||||
|
||||
DiagnosticExtractorError() {
|
||||
this = TExtractorError(e) and
|
||||
not exists(CompilerError ce | ce.getLocation().getFile() = e.getLocation().getFile())
|
||||
}
|
||||
|
||||
override string getMessage() {
|
||||
result =
|
||||
"Unexpected " + e.getOrigin() + " error" + getLocation(e.getLocation()) + ": " + e.getText()
|
||||
}
|
||||
|
||||
override string toString() { result = e.toString() }
|
||||
}
|
||||
|
||||
from DiagnosticError error
|
||||
select error.getMessage(), 3
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @name Successfully extracted files
|
||||
* @description A list of all files in the source code directory that were extracted
|
||||
* without encountering an extraction error in the file.
|
||||
* without encountering an extraction or compiler error in the file.
|
||||
* @kind diagnostic
|
||||
* @id cs/diagnostics/successfully-extracted-files
|
||||
*/
|
||||
@@ -10,5 +10,8 @@ import csharp
|
||||
import semmle.code.csharp.commons.Diagnostics
|
||||
|
||||
from File file
|
||||
where file.fromSource() and not exists(ExtractorError e | e.getLocation().getFile() = file)
|
||||
where
|
||||
file.fromSource() and
|
||||
not exists(ExtractorError e | e.getLocation().getFile() = file) and
|
||||
not exists(CompilerError e | e.getLocation().getFile() = file)
|
||||
select file, ""
|
||||
|
||||
@@ -1 +1 @@
|
||||
| Program.cs:9:32:9:46 | Unable to resolve target for call. (Compilation error?) | Unexpected C# extractor error in Program.cs: Unable to resolve target for call. (Compilation error?) | 3 |
|
||||
| Unexpected C# extractor error in Program.cs: Unable to resolve target for call. (Compilation error?) | 3 |
|
||||
|
||||
Reference in New Issue
Block a user