forked from phoedos/pmd
@ -367,6 +367,7 @@ Language specific fixes:
|
||||
* [#2946](https://github.com/pmd/pmd/issues/2946): \[java] SwitchStmtsShouldHaveDefault false positive on enum inside enums
|
||||
* [#3672](https://github.com/pmd/pmd/pull/3672): \[java] LooseCoupling - fix false positive with generics
|
||||
* [#3675](https://github.com/pmd/pmd/pull/3675): \[java] MissingOverride - fix false positive with mixing type vars
|
||||
* [#3858](https://github.com/pmd/pmd/issues/3858): \[java] UseCollectionIsEmpty should infer local variable type from method invocation
|
||||
* java-codestyle
|
||||
* [#1208](https://github.com/pmd/pmd/issues/1208): \[java] PrematureDeclaration rule false-positive on variable declared to measure time
|
||||
* [#1429](https://github.com/pmd/pmd/issues/1429): \[java] PrematureDeclaration as result of method call (false positive)
|
||||
|
@ -543,4 +543,29 @@ public record Record(Set<String> stringSet) {
|
||||
}
|
||||
} ]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>[java] UseCollectionIsEmpty should infer local variable type from method invocation #3858</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>8</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Example {
|
||||
|
||||
public void func() {
|
||||
var list = getList();
|
||||
if (list.size()>0) { // point 1: false negative
|
||||
System.out.println("!list.isEmpty() is better!");
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getList() { // mock
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user