Merge pull request #17442 from geoffw0/files

Rust: Extracted Files diagnostic query
This commit is contained in:
Geoffrey White
2024-09-13 14:13:43 +01:00
committed by GitHub
8 changed files with 92 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
/**
* @name Extracted files
* @description Lists all files in the source code directory that were extracted.
* @kind diagnostic
* @id rust/diagnostics/successfully-extracted-files
* @tags successfully-extracted-files
*/
import rust
from File f
where exists(f.getRelativePath())
select f, "File successfully extracted."

View File

@@ -0,0 +1,6 @@
| does_not_compile.rs:0:0:0:0 | does_not_compile.rs | File successfully extracted. |
| error.rs:0:0:0:0 | error.rs | File successfully extracted. |
| lib.rs:0:0:0:0 | lib.rs | File successfully extracted. |
| main.rs:0:0:0:0 | main.rs | File successfully extracted. |
| my_macro.rs:0:0:0:0 | my_macro.rs | File successfully extracted. |
| my_struct.rs:0:0:0:0 | my_struct.rs | File successfully extracted. |

View File

@@ -0,0 +1 @@
queries/diagnostics/ExtractedFiles.ql

View File

@@ -0,0 +1,3 @@
pub fn my_func() {
This is not correct Rust code.
}

View File

@@ -0,0 +1,3 @@
pub fn my_func() {
compile_error!("An error!");
}

View File

@@ -0,0 +1,18 @@
/**
* total lines in this file: 18
* of which code: 7
* of which only comments: 7
* of which blank: 4
*/
mod my_struct;
mod my_macro;
// another comment
fn main() {
println!("Hello, world!"); // another comment
my_struct::my_func();
my_macro::my_func();
}

View File

@@ -0,0 +1,18 @@
/**
* total lines in this file: 18
* of which code: 10
* of which only comments: 6
* of which blank: 2
*/
macro_rules! myMacro {
() => {
println!("Hello, world!");
};
}
pub fn my_func() {
if true {
myMacro!();
}
}

View File

@@ -0,0 +1,30 @@
#![allow(dead_code)]
/**
* total lines in this file: 30
* of which code: 20
* of which only comments: 6
* of which blank: 4
*/
#[derive(Debug)]
struct MyStruct {
name: String,
value: i32,
}
impl MyStruct {
fn my_method(&self) {
println!("Hello, world!");
}
}
pub fn my_func() {
let _a = 1;
let b =
MyStruct {
name: String::from("abc"),
value: 123,
};
b.my_method();
}