diff --git a/ql/src/queries/diagnostics/ExtractionErrors.ql b/ql/src/queries/diagnostics/ExtractionErrors.ql new file mode 100644 index 00000000000..224f0d23c47 --- /dev/null +++ b/ql/src/queries/diagnostics/ExtractionErrors.ql @@ -0,0 +1,18 @@ +/** + * @name Extraction errors + * @description List all extraction errors for files in the source code directory. + * @kind diagnostic + * @id rb/diagnostics/extraction-errors + */ + +import ruby +import codeql_ruby.Diagnostics + +/** Gets the SARIF severity to associate an error. */ +int getSeverity() { result = 2 } + +from ExtractionError error, File f +where + f = error.getLocation().getFile() and + exists(f.getRelativePath()) +select error, "Extraction failed in " + f + " with error " + error.getMessage(), getSeverity() diff --git a/ql/src/queries/diagnostics/FilesExtractedWithErrors.ql b/ql/src/queries/diagnostics/FilesExtractedWithErrors.ql deleted file mode 100644 index 8db409eefd1..00000000000 --- a/ql/src/queries/diagnostics/FilesExtractedWithErrors.ql +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @name Files extracted with errors - * @description Lists files that were extracted, but may be incomplete due to - * extraction errors. - * @kind diagnostic - * @id rb/diagnostics/files-extracted-with-errors - */ - -import ruby -import codeql_ruby.Diagnostics - -from File f -where exists(ExtractionError e | e.getLocation().getFile() = f) -select f, "" diff --git a/ql/src/queries/diagnostics/SuccessfullyExtractedFiles.ql b/ql/src/queries/diagnostics/SuccessfullyExtractedFiles.ql index f7c3bbd14af..3bc58c3467d 100644 --- a/ql/src/queries/diagnostics/SuccessfullyExtractedFiles.ql +++ b/ql/src/queries/diagnostics/SuccessfullyExtractedFiles.ql @@ -1,7 +1,7 @@ /** * @name Successfully extracted files - * @description Lists all files that were extracted without encountering an - * error in the file. + * @description Lists all files in the source code directory that were extracted + * without encountering an error in the file. * @kind diagnostic * @id rb/diagnostics/successfully-extracted-files */ @@ -10,5 +10,7 @@ import ruby import codeql_ruby.Diagnostics from File f -where not exists(ExtractionError e | e.getLocation().getFile() = f) +where + not exists(ExtractionError e | e.getLocation().getFile() = f) and + exists(f.getRelativePath()) select f, "" diff --git a/ql/src/queries/summary/NumberOfSuccesfullyExtractedFiles.ql b/ql/src/queries/summary/NumberOfSuccessfullyExtractedFiles.ql similarity index 100% rename from ql/src/queries/summary/NumberOfSuccesfullyExtractedFiles.ql rename to ql/src/queries/summary/NumberOfSuccessfullyExtractedFiles.ql