[Rust] Unused variable false positive in compound conditional statements
- Ngôn ngữ chính
- CodeQL
- Star
- 10.1k
- Fork
- 2.1k
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 141
Mô tả
**Description of the false positive**
When there is an if-let statement, and multiple conditions exist in the conditional check (either AND or OR as operators), CodeQL flags the original variable as unused if it is used in subsequent conditional statements.
**Code samples or links to source code**
There are many dismissed false positives linked to this merged PR:
A small example would be:
```rust
for result in builder.build() {
match result {
Ok(entry) => {
if let Some(file_type) = entry.file_type()
&& file_type.is_file()
{
paths.push(entry.path().to_path_buf());
}
}
Err(msg) => eprintln!("Error reading entry: {msg}"),
}
}
```
Here, `file_type` was flagged as a false positive, even though it is used in the following boolean statement `file_type.is_file()`.
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.