[Rust] Unused variable false positive in compound conditional statements
- 主要语言
- CodeQL
- 星标
- 10.1k
- 派生
- 2.1k
- 平均合并
- 2 天 15 小时
- 30 天内合并 PR
- 141
描述
**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()`.
贡献指南
评估
这个 Issue 还没有评估数据。