A RetroSearch Logo

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

Search Query:

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

[java] UnusedPrivateMethod false positive when passing in lombok.val as argument · Issue #3118 · pmd/pmd · GitHub

Affects PMD Version: 6.31.0

Rule: UnusedPrivateMethod

Description: Passing an argument defined using Lombok's val to a private method is not recognized as usage of that method by PMD. PMD's behavior for Lombok val should be similar to its handling of Java 10's var keyword. Changing the below test to use var instead of Lombok val leads to the test passing.

Code Sample demonstrating the issue:
I'm able to reproduce the issue by adding the test-code block below to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml

    <test-code>
        <description>Lombok.val should not fail</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import lombok.val;

public class ValExample {
    public void example() {
        val example = "value";
        aPrivateMethod(example);
    }

    private void aPrivateMethod(String s) {
        System.out.println(s);
    }
}
        ]]></code>
    </test-code>

Expected outcome:
PMD should not report a violation in this case because the method is actually used.

Running PMD through: Maven


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