GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] UnusedPrivateMethod false positive when passing in lombok.val as argument · Issue #3118 · pmd/pmd

[java] UnusedPrivateMethod false positive when passing in lombok.val as argument #3118

New issue
Copy link
New issue
Copy link
Closed
#3157
Closed
[java] UnusedPrivateMethod false positive when passing in lombok.val as argument#3118
#3157
Copy link
Labels
a:false-positivePMD flags a piece of code that is not problematic
Milestone
6.33.0

Description

@dzeigler
dzeigler
opened on Feb 16, 2021
Issue body actions

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

Activity

  1. dzeigler
    added
    a:false-negativePMD doesn't flag a problematic piece of code
    a:false-positivePMD flags a piece of code that is not problematic
    on Feb 16, 2021
  2. dzeigler
    changed the title [-][java] False positive for UnusedPrivateMethod when passing in Lombok val as argument[/-] [+][java] UnusedPrivateMethod false positive when passing in Lombok val as argument[/+] on Feb 16, 2021
  3. oowekyala
    removed
    a:false-negativePMD doesn't flag a problematic piece of code
    on Feb 16, 2021
  4. adangel
    changed the title [-][java] UnusedPrivateMethod false positive when passing in Lombok val as argument[/-] [+][java] UnusedPrivateMethod false positive when passing in lombok.val as argument[/+] on Mar 4, 2021
  5. adangel
    added a commit that references this issue on Mar 4, 2021

    [java] UnusedPrivateMethod false positive when passing in lombok.val as

    This issue will close once commit 3593b4d is merged into the 'main' branch.
    3593b4d
  6. adangel
    added this to the 6.33.0 milestone on Mar 4, 2021
  7. adangel
    closed this as completedin #3157on Mar 27, 2021
  8. adangel
    closed this as completedin 3593b4don Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type

    Projects

    No projects

      Milestone

      • 6.33.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.