mirror of
https://github.com/github/codeql.git
synced 2025-12-16 08:43:11 +01:00
Merge pull request #21009 from geoffw0/varfps
Rust: Fix some false positives for rust/unused-variable and rust/unused-value
This commit is contained in:
4
rust/ql/src/change-notes/2025-12-10-unused-variable.md
Normal file
4
rust/ql/src/change-notes/2025-12-10-unused-variable.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* Fixed common false positives for the `rust/unused-variable` and `rust/unused-value` queries.
|
||||
@@ -43,4 +43,10 @@ predicate isAllowableUnused(Variable v) {
|
||||
or
|
||||
// a 'self' variable
|
||||
v.getText() = "self"
|
||||
or
|
||||
// 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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user