From a72ac5845b20f26552327d090ffd468a498298c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 15 Nov 2024 16:14:09 +0100 Subject: [PATCH] Add test for #5113 --- .../bestpractices/xml/UnusedPrivateMethod.xml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml index 1a6dd1488d..ae0fc5e242 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml @@ -2218,4 +2218,24 @@ public class ObtainViaTest { } ]]> + + + UnusedPrivateMethod #5113 + 0 + foo(int param) { + var optional = param == 0 ? Optional.of(true) : Optional.of(false); + return optional.flatMap(this::dummy); + } + + private Optional dummy(boolean foo) { + return Optional.of(foo); + } + } + ]]> + +