Skip to content

Commit

Permalink
Add test case for pmd#3802
Browse files Browse the repository at this point in the history
  • Loading branch information
jsotuyod committed Mar 18, 2024
1 parent e7ec34e commit 6be72b2
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,37 @@ class LawOfDemeterFields {
return null;
}
}
]]></code>
</test-code>

<test-code>
<description>#3802 FN with lambdas</description>
<expected-problems>1</expected-problems>
<expected-linenumbers>7</expected-linenumbers>
<code><![CDATA[
import java.util.function.Function;
public class Example {
public void func() {
MyObject myObject = MyObjectProvider.get();
Function<Integer, Integer> f = (i) -> {
Object obj = myObject.getFunc(); //false-negative here
obj.hashCode();
};
}
}
class MyObject {
public Object getFunc(){
return new Object();
}
}
class MyObjectProvider {
public static MyObject get(){
return new MyObject();
}
}
]]></code>
</test-code>
</test-data>

0 comments on commit 6be72b2

Please sign in to comment.