A false negative about the rule INEFFICIENT_KEYSET_ITERATOR
- Dominant language
- OCaml
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 19h 36m
- Merged PRs (30d)
- 13
Description
Infer version: v1.1.0
OS: Ubuntu 20
Command:
```bash
infer run --inefficient-keyset-iterator -- javac Example.java
```
The following code example can be detected:
```java
void inefficient_loop_itr_bad(HashMap testMap) {
Iterator itr2 = testMap.keySet().iterator();
while (itr2.hasNext()) {
String key = (String) itr2.next();
testMap.get(key); // can report a warning here
}
}
```
However, it cannot detect the do-while loop:
```java
void inefficient_loop_itr_bad(HashMap testMap) {
Iterator itr2 = testMap.keySet().iterator();
do {
String key = (String) itr2.next();
testMap.get(key); // no warnings at this line
} while (itr2.hasNext());
}
```
These two code examples are equivalent, hence, I think this is a false negative.
Contributor guide
Assessment
This issue has not been assessed yet.