forked from phoedos/pmd
[java] UnusedLocalVariable - add test case from #3656
This commit is contained in:
parent
3929cac930
commit
c9c7d05ac7
@ -391,6 +391,24 @@ public class UnusedLocalVariable {
|
||||
int ignored, unused = 0;
|
||||
int notok = 0;
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>False positive with try-with-resources</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.InputStream;
|
||||
public class UsedLocalVar {
|
||||
public boolean run() {
|
||||
boolean canRead = false;
|
||||
try(InputStream resource = open()) {
|
||||
canRead = true;
|
||||
} catch (Throwable ignore) {}
|
||||
return canRead;
|
||||
}
|
||||
private InputStream open() { return null; }
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
Loading…
x
Reference in New Issue
Block a user