Skip to content

Commit c596205

Browse files
committed
Rust: add some more diagnostics queries
1 parent bdb4d89 commit c596205

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @name Extraction errors
3+
* @description List all extraction errors for files in the source code directory.
4+
* @kind diagnostic
5+
* @id rust/diagnostics/extraction-errors
6+
*/
7+
8+
import codeql.rust.Diagnostics
9+
import codeql.files.FileSystem
10+
11+
/** Gets the SARIF severity to associate an error. */
12+
int getSeverity() { result = 2 }
13+
14+
from ExtractionError error, File f
15+
where
16+
f = error.getLocation().getFile() and
17+
exists(f.getRelativePath())
18+
select error, "Extraction failed in " + f + " with error " + error.getMessage(), getSeverity()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @id rust/summary/number-of-files-extracted-with-errors
3+
* @name Total number of Rust files that were extracted with errors
4+
* @description The total number of Rust code files that we extracted, but where
5+
* at least one extraction error occurred in the process.
6+
* @kind metric
7+
* @tags summary
8+
*/
9+
10+
import codeql.files.FileSystem
11+
import codeql.rust.Diagnostics
12+
13+
select count(File f |
14+
exists(ExtractionError e | e.getLocation().getFile() = f) and exists(f.getRelativePath())
15+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @id rust/summary/number-of-successfully-extracted-files
3+
* @name Total number of Rust files that were extracted without error
4+
* @description The total number of Rust code files that we extracted without
5+
* encountering any extraction errors
6+
* @kind metric
7+
* @tags summary
8+
*/
9+
10+
import codeql.rust.Diagnostics
11+
import codeql.files.FileSystem
12+
13+
select count(File f |
14+
not exists(ExtractionError e | e.getLocation().getFile() = f) and exists(f.getRelativePath())
15+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| does_not_compile.rs:2:6:2:5 | expected SEMICOLON | Extraction failed in does_not_compile.rs with error expected SEMICOLON | 2 |
2+
| does_not_compile.rs:2:9:2:8 | expected SEMICOLON | Extraction failed in does_not_compile.rs with error expected SEMICOLON | 2 |
3+
| does_not_compile.rs:2:13:2:12 | expected SEMICOLON | Extraction failed in does_not_compile.rs with error expected SEMICOLON | 2 |
4+
| does_not_compile.rs:2:21:2:20 | expected SEMICOLON | Extraction failed in does_not_compile.rs with error expected SEMICOLON | 2 |
5+
| does_not_compile.rs:2:26:2:25 | expected SEMICOLON | Extraction failed in does_not_compile.rs with error expected SEMICOLON | 2 |
6+
| does_not_compile.rs:2:32:2:31 | expected field name or number | Extraction failed in does_not_compile.rs with error expected field name or number | 2 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
queries/diagnostics/ExtractionErrors.ql

0 commit comments

Comments
 (0)