#1286 UnusedPrivateMethod returns false positives for varags and enums

PMD-5.2.2
closed
None
PMD
3-Major
Bug
5.2.1
2014-12-03
2014-11-25
No

I tried to update from PMD 5.1.1 to 5.2.1 but I have encountered a number of UnusedPrivateMethod false positives in relation to methods with varags.

This is a simple example I have come up with

public class VaragsFalsePositive {

    enum Sizes
    {
        TINY,
        MEDIUM
    }

    public boolean containsTiny(){
        return hasTiny(Sizes.MEDIUM, Sizes.TINY);
    }

    private boolean hasTiny(Sizes... sizes) {
        for (Sizes size : sizes) {
            if (size==Sizes.TINY) {
                return true;
            }
        }
        return false;
    }
}

With PMD 5.2.1 I get :

PMD Failure: VaragsFalsePositive:18 Rule:UnusedPrivateMethod Priority:3 Avoid unused private methods such as 'hasTiny(Sizes...)'..

With PMD 5.1.1 no issues with the above.

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-11-26
    • status: open --> duplicate
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-Next
     
  • Andreas Dangel

    Andreas Dangel - 2014-11-26

    This will be solved with 5.2.2.

    Probably a duplicate/similar case like [#1281], [#1276]

     

    Related

    Issues: #1276
    Issues: #1281


    Last edit: Andreas Dangel 2014-11-26
  • Andreas Dangel

    Andreas Dangel - 2014-11-26
    • status: duplicate --> in-progress
     
  • Andreas Dangel

    Andreas Dangel - 2014-11-26

    It's actually failing, in case auxclasspath option is in use.

     
  • Andreas Dangel

    Andreas Dangel - 2014-11-26
    • summary: UnusedPrivateMethod returns false positives for varags --> UnusedPrivateMethod returns false positives for varags and enums
    • status: in-progress --> closed
     
  • Andreas Dangel

    Andreas Dangel - 2014-11-26

    Thanks for catching this! It will be fixed with 5.2.2.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks