MustBeClosedChecker - False positive due to variable declaration without expression
Open
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
Looking at [this line](https://github.com/google/error-prone/blob/d19024b059d9db804045fdc992c9f6f3ff073769/core/src/main/java/com/google/errorprone/bugpatterns/AbstractMustBeClosedChecker.java#L303) of code, I believe that we should be looking for the next statement that is not an empty variable declaration.
For example:
```
Closeable closeable = getCloseable();
@var SomeVariable x;
try {
// code here
} finally {
closeable.close();
}
```
I believe that since there is no expression on the RHS of the SomeVariable declaration, that the closeable is indeed guaranteed to be closed.
Contributor guide
Assessment
This issue has not been assessed yet.