facebook / facebook/infer

A False Negative in INEFFICIENT_KEYSET_ITERATOR Detection​

Open
#1,948 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
OCaml
Stars
15.7k
Forks
2.1k
Avg merge
19h 36m
Merged PRs (30d)
13

Description

In the following code example, there is an `INEFFICIENT_KEYSET_ITERATOR` issue at line 8. However, Infer fails to report this warning, resulting in a false negative.

### Minimized Code Example
```java
import java.util.HashMap;
public class Main {
public static void main(String[] args) {
HashMap map = new HashMap<>();
map.keySet()
.forEach(
key -> {
String s = map.get(key); // should report a warning, but no warnings
if (s.equals("foo")) {
System.out.println("true");
}
});
}
}
```

### Analysis Log
```bash
Capturing in javac mode...
Found 1 source file to analyze in /.../infer-out
0/8 [................................................................................] 0% 116ms
⊢ [ 0.1s][ 8.8M] idle
⊢ [ 0.1s][ 8.8M] idle
4/8 [########################################........................................] 50% 184ms
⊢ [ 0.0s][ 8.8M] Main.java
⊢ [ 0.2s][ 8.8M] idle
8/8 [################################################################################] 100% 192ms
⊢ [ 0.0s][ 8.8M] idle
⊢ [ 0.0s][ 8.8M] idle
⊢ [ 0.0s][10.2M] idle

No issues found
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.