From 40dcc0e7aed5250ae852d6bce713cc4cddf37ca9 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Tue, 29 Oct 2024 14:02:16 +0100 Subject: [PATCH] Rust: Include variable name in `Unused{Variable,Value}.ql` --- .../src/queries/unusedentities/UnusedValue.ql | 2 +- .../queries/unusedentities/UnusedVariable.ql | 2 +- .../unusedentities/UnusedValue.expected | 48 +++++++++---------- .../unusedentities/UnusedVariable.expected | 42 ++++++++-------- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/rust/ql/src/queries/unusedentities/UnusedValue.ql b/rust/ql/src/queries/unusedentities/UnusedValue.ql index 6070927f640b3..d820858417dd6 100644 --- a/rust/ql/src/queries/unusedentities/UnusedValue.ql +++ b/rust/ql/src/queries/unusedentities/UnusedValue.ql @@ -21,4 +21,4 @@ where // avoid overlap with the unused variable query not isUnused(v) and not v instanceof DiscardVariable -select write, "Variable is assigned a value that is never used." +select write, "Variable '" + v + "' is assigned a value that is never used." diff --git a/rust/ql/src/queries/unusedentities/UnusedVariable.ql b/rust/ql/src/queries/unusedentities/UnusedVariable.ql index 0162d32ff8a3a..339bb0967fbfa 100644 --- a/rust/ql/src/queries/unusedentities/UnusedVariable.ql +++ b/rust/ql/src/queries/unusedentities/UnusedVariable.ql @@ -13,4 +13,4 @@ import UnusedVariable from Variable v where isUnused(v) -select v, "Variable is not used." +select v, "Variable '" + v + "' is not used." diff --git a/rust/ql/test/query-tests/unusedentities/UnusedValue.expected b/rust/ql/test/query-tests/unusedentities/UnusedValue.expected index e2d0fa11faab8..ce89c8ff06bff 100644 --- a/rust/ql/test/query-tests/unusedentities/UnusedValue.expected +++ b/rust/ql/test/query-tests/unusedentities/UnusedValue.expected @@ -1,24 +1,24 @@ -| main.rs:6:9:6:9 | a | Variable is assigned a value that is never used. | -| main.rs:9:9:9:9 | d | Variable is assigned a value that is never used. | -| main.rs:35:5:35:5 | b | Variable is assigned a value that is never used. | -| main.rs:37:5:37:5 | c | Variable is assigned a value that is never used. | -| main.rs:40:5:40:5 | c | Variable is assigned a value that is never used. | -| main.rs:44:9:44:9 | d | Variable is assigned a value that is never used. | -| main.rs:50:5:50:5 | e | Variable is assigned a value that is never used. | -| main.rs:61:5:61:5 | f | Variable is assigned a value that is never used. | -| main.rs:63:5:63:5 | f | Variable is assigned a value that is never used. | -| main.rs:65:5:65:5 | g | Variable is assigned a value that is never used. | -| main.rs:87:9:87:9 | a | Variable is assigned a value that is never used. | -| main.rs:108:9:108:10 | is | Variable is assigned a value that is never used. | -| main.rs:131:13:131:17 | total | Variable is assigned a value that is never used. | -| main.rs:194:13:194:31 | res | Variable is assigned a value that is never used. | -| main.rs:206:9:206:24 | kind | Variable is assigned a value that is never used. | -| main.rs:210:9:210:32 | kind | Variable is assigned a value that is never used. | -| main.rs:266:13:266:17 | total | Variable is assigned a value that is never used. | -| main.rs:334:5:334:39 | kind | Variable is assigned a value that is never used. | -| main.rs:359:9:359:9 | x | Variable is assigned a value that is never used. | -| main.rs:367:17:367:17 | x | Variable is assigned a value that is never used. | -| more.rs:24:9:24:11 | val | Variable is assigned a value that is never used. | -| more.rs:44:9:44:14 | a_ptr4 | Variable is assigned a value that is never used. | -| more.rs:59:9:59:13 | d_ptr | Variable is assigned a value that is never used. | -| more.rs:65:9:65:17 | f_ptr | Variable is assigned a value that is never used. | +| main.rs:6:9:6:9 | a | Variable 'a' is assigned a value that is never used. | +| main.rs:9:9:9:9 | d | Variable 'd' is assigned a value that is never used. | +| main.rs:35:5:35:5 | b | Variable 'b' is assigned a value that is never used. | +| main.rs:37:5:37:5 | c | Variable 'c' is assigned a value that is never used. | +| main.rs:40:5:40:5 | c | Variable 'c' is assigned a value that is never used. | +| main.rs:44:9:44:9 | d | Variable 'd' is assigned a value that is never used. | +| main.rs:50:5:50:5 | e | Variable 'e' is assigned a value that is never used. | +| main.rs:61:5:61:5 | f | Variable 'f' is assigned a value that is never used. | +| main.rs:63:5:63:5 | f | Variable 'f' is assigned a value that is never used. | +| main.rs:65:5:65:5 | g | Variable 'g' is assigned a value that is never used. | +| main.rs:87:9:87:9 | a | Variable 'a' is assigned a value that is never used. | +| main.rs:108:9:108:10 | is | Variable 'is' is assigned a value that is never used. | +| main.rs:131:13:131:17 | total | Variable 'total' is assigned a value that is never used. | +| main.rs:194:13:194:31 | res | Variable 'res' is assigned a value that is never used. | +| main.rs:206:9:206:24 | kind | Variable 'kind' is assigned a value that is never used. | +| main.rs:210:9:210:32 | kind | Variable 'kind' is assigned a value that is never used. | +| main.rs:266:13:266:17 | total | Variable 'total' is assigned a value that is never used. | +| main.rs:334:5:334:39 | kind | Variable 'kind' is assigned a value that is never used. | +| main.rs:359:9:359:9 | x | Variable 'x' is assigned a value that is never used. | +| main.rs:367:17:367:17 | x | Variable 'x' is assigned a value that is never used. | +| more.rs:24:9:24:11 | val | Variable 'val' is assigned a value that is never used. | +| more.rs:44:9:44:14 | a_ptr4 | Variable 'a_ptr4' is assigned a value that is never used. | +| more.rs:59:9:59:13 | d_ptr | Variable 'd_ptr' is assigned a value that is never used. | +| more.rs:65:9:65:17 | f_ptr | Variable 'f_ptr' is assigned a value that is never used. | diff --git a/rust/ql/test/query-tests/unusedentities/UnusedVariable.expected b/rust/ql/test/query-tests/unusedentities/UnusedVariable.expected index 804a0849e7aad..216f86ee81707 100644 --- a/rust/ql/test/query-tests/unusedentities/UnusedVariable.expected +++ b/rust/ql/test/query-tests/unusedentities/UnusedVariable.expected @@ -1,21 +1,21 @@ -| main.rs:25:9:25:9 | a | Variable is not used. | -| main.rs:90:13:90:13 | d | Variable is not used. | -| main.rs:139:5:139:5 | y | Variable is not used. | -| main.rs:166:9:166:9 | x | Variable is not used. | -| main.rs:236:17:236:17 | a | Variable is not used. | -| main.rs:244:20:244:22 | val | Variable is not used. | -| main.rs:258:14:258:16 | val | Variable is not used. | -| main.rs:273:22:273:24 | val | Variable is not used. | -| main.rs:280:24:280:26 | val | Variable is not used. | -| main.rs:288:13:288:15 | num | Variable is not used. | -| main.rs:303:12:303:12 | j | Variable is not used. | -| main.rs:323:25:323:25 | y | Variable is not used. | -| main.rs:326:28:326:28 | a | Variable is not used. | -| main.rs:329:9:329:9 | p | Variable is not used. | -| main.rs:347:9:347:13 | right | Variable is not used. | -| main.rs:353:9:353:14 | right2 | Variable is not used. | -| main.rs:360:13:360:13 | y | Variable is not used. | -| main.rs:368:21:368:21 | y | Variable is not used. | -| main.rs:413:26:413:28 | val | Variable is not used. | -| main.rs:416:21:416:23 | acc | Variable is not used. | -| main.rs:437:9:437:14 | unused | Variable is not used. | +| main.rs:25:9:25:9 | a | Variable 'a' is not used. | +| main.rs:90:13:90:13 | d | Variable 'd' is not used. | +| main.rs:139:5:139:5 | y | Variable 'y' is not used. | +| main.rs:166:9:166:9 | x | Variable 'x' is not used. | +| main.rs:236:17:236:17 | a | Variable 'a' is not used. | +| main.rs:244:20:244:22 | val | Variable 'val' is not used. | +| main.rs:258:14:258:16 | val | Variable 'val' is not used. | +| main.rs:273:22:273:24 | val | Variable 'val' is not used. | +| main.rs:280:24:280:26 | val | Variable 'val' is not used. | +| main.rs:288:13:288:15 | num | Variable 'num' is not used. | +| main.rs:303:12:303:12 | j | Variable 'j' is not used. | +| main.rs:323:25:323:25 | y | Variable 'y' is not used. | +| main.rs:326:28:326:28 | a | Variable 'a' is not used. | +| main.rs:329:9:329:9 | p | Variable 'p' is not used. | +| main.rs:347:9:347:13 | right | Variable 'right' is not used. | +| main.rs:353:9:353:14 | right2 | Variable 'right2' is not used. | +| main.rs:360:13:360:13 | y | Variable 'y' is not used. | +| main.rs:368:21:368:21 | y | Variable 'y' is not used. | +| main.rs:413:26:413:28 | val | Variable 'val' is not used. | +| main.rs:416:21:416:23 | acc | Variable 'acc' is not used. | +| main.rs:437:9:437:14 | unused | Variable 'unused' is not used. |