Affects PMD Version: 7.7.0
Rule: UnusedPrivateMethod
Description:
Code Sample demonstrating the issue:
private String foo(final Object foo, final String bar) { final String abc = Optional.ofNullable(foo.toString()).map(Foo::getNormalizedAddress).orElse(null); return abc; } private static String getNormalizedAddress(final String encoded) { try (var objectInputStream = new ObjectInputStream(new ByteArrayInputStream(Base64.getDecoder().decode(encoded)))) { final var inetSocketAddress = (InetSocketAddress) objectInputStream.readObject(); return inetSocketAddress.toString().substring(1); } catch (IOException | ClassNotFoundException | IllegalArgumentException e) { return null; } }
Expected outcome:
PMD reports a violation at line ..., but that's wrong. That's a false positive.
The method is clearly being used
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
Maven
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.26.0</version>
</plugin>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4