diff --git a/ql/src/codeql_ruby/Diagnostics.qll b/ql/src/codeql_ruby/Diagnostics.qll index 4e35a9a5dd1..e2e28a84b07 100644 --- a/ql/src/codeql_ruby/Diagnostics.qll +++ b/ql/src/codeql_ruby/Diagnostics.qll @@ -2,30 +2,54 @@ private import codeql.Locations /** A diagnostic emitted during extraction, such as a parse error */ class Diagnostic extends @diagnostic { + int severity; + string tag; + string message; + string fullMessage; + Location location; + + Diagnostic() { diagnostics(this, severity, tag, message, fullMessage, location) } + /** * Gets the numerical severity level associated with this diagnostic. */ - int getSeverity() { diagnostics(this, result, _, _, _, _) } + int getSeverity() { result = severity } + + /** Gets a string representation of the severity of this diagnostic. */ + string getSeverityText() { + severity = 0 and result = "Hidden" + or + severity = 1 and result = "Info" + or + severity = 2 and result = "Warning" + or + severity = 3 and result = "Error" + } /** Gets the error code associated with this diagnostic, e.g. parse_error. */ - string getTag() { diagnostics(this, _, result, _, _, _) } + string getTag() { result = tag } /** * Gets the error message text associated with this diagnostic. */ - string getMessage() { diagnostics(this, _, _, result, _, _) } + string getMessage() { result = message } /** * Gets the full error message text associated with this diagnostic. */ - string getFullMessage() { diagnostics(this, _, _, _, result, _) } + string getFullMessage() { result = fullMessage } /** Gets the source location of this diagnostic. */ - Location getLocation() { diagnostics(this, _, _, _, _, result) } + Location getLocation() { result = location } + /** Gets a textual representation of this diagnostic. */ string toString() { result = this.getMessage() } } +/** A diagnostic relating to a particular error in extracting a file. */ class ExtractionError extends Diagnostic { - ExtractionError() { this.getTag() = "parse_error" } -} \ No newline at end of file + ExtractionError() { + this.getSeverity() = 3 and + this.getTag() = "parse_error" + } +}