A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/5184 below:

[java] UnusedPrivateMethod false-positive used in lambda · Issue #5184 · pmd/pmd · GitHub

Affects PMD Version: 7.3.0

Rule:

Please provide the rule name and a link to the rule documentation:
https://docs.pmd-code.org/latest/pmd_rules_java_bestpractices.html#unusedprivatemethod

Description:
Avoid unused private methods such as 'registerUser(String, String, String)'.

Code Sample demonstrating the issue:

public User methodA() {
    val user = userOpt.orElseGet(() -> {
        try {
            return registerUser(email, firstName, lastName);
        } catch (Exception e) {
           throw new IllegalStateException("Failed to register user for " + email, e);
        }
    };
   // ...
   return user;
}

private User registerUser(String email, String firstName, String lastName) throws Exception {
    // register user logic here... 
}

Expected outcome:

No UnusedPrivateMethod violation should be reported here.

PMD reports a violation at line of the private method 'registerUser' but that's wrong. That's a false positive.

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
[Maven] with maven-pmd-plugin version 3.25.


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