mirror of
https://github.com/github/codeql.git
synced 2025-12-16 08:43:11 +01:00
Rust: Narrow the exclusion a little.
This commit is contained in:
@@ -44,7 +44,9 @@ predicate isAllowableUnused(Variable v) {
|
||||
// a 'self' variable
|
||||
v.getText() = "self"
|
||||
or
|
||||
// a common source of false positives is match arms that are misrecognized as
|
||||
// a variable, having not been correctly resolved
|
||||
v.getPat().getParentNode() instanceof MatchArm
|
||||
// a common source of false positives is match arms containing constants
|
||||
// (typically beginning with a capital letter) that are misrecognized as a
|
||||
// variable, having not been correctly resolved.
|
||||
v.getPat().getParentNode() instanceof MatchArm and
|
||||
v.getText().charAt(0).isUppercase()
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
| main.rs:307:13:307:15 | num | Variable 'num' is not used. |
|
||||
| main.rs:342:25:342:25 | y | Variable 'y' is not used. |
|
||||
| main.rs:345:28:345:28 | a | Variable 'a' is not used. |
|
||||
| main.rs:348:9:348:9 | p | Variable 'p' is not used. |
|
||||
| main.rs:366:9:366:13 | right | Variable 'right' is not used. |
|
||||
| main.rs:372:9:372:14 | right2 | Variable 'right2' is not used. |
|
||||
| main.rs:383:13:383:13 | y | Variable 'y' is not used. |
|
||||
|
||||
@@ -345,7 +345,7 @@ fn if_lets_matches() {
|
||||
MyPoint { x: 3, y: a } => { // $ Alert[rust/unused-variable]
|
||||
}
|
||||
MyPoint { x: 4, .. } => {}
|
||||
p => { // $ MISSING: Alert[rust/unused-variable]
|
||||
p => { // $ Alert[rust/unused-variable]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user