Menu

#1279 False positive in UnusedPrivateMethod when param is result of method in parent class

New Tickets
more-info-needed
None
PMD
3-Major
Bug
PMD-5.2.1
2016-06-25
2014-11-10
No

PMD 5.2.1 reports a method as unused when one of the arguments of type String is called using the result of a method in a parent class.

Example
public class SomeParent {
public String getName() { ... }
}
public class SomeChild extends SomeParent {
// do not override getName
}
public class SomeTest {
public someMethod(SomeChild child) {
doSomething(child.getName());
}

// this method is flagged as unused
// because it is called using "child.getName()"
// the workaround is to cast the call to String
private void doSomething(String name) {
    // do some stuff
}

}

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-11-14
    • status: open --> more-info-needed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-Next
     
  • Andreas Dangel

    Andreas Dangel - 2014-11-14

    I can't reproduce this either.
    Please checkout the attached zipfile for the test case I used and let me know, if this is really your example case.

    Thanks,
    Andreas

     
  • Andreas Dangel

    Andreas Dangel - 2014-12-03

    Hi, could you please test, whether this is still an issue with the version 5.2.2? Thanks!

     
  • Andreas Dangel

    Andreas Dangel - 2014-12-03
    • Milestone: PMD-5.2.2 --> PMD-Next
     
  • Andreas Dangel

    Andreas Dangel - 2014-12-21
    • Milestone: PMD-5.2.3 --> PMD-Next
     
  • Andreas Dangel

    Andreas Dangel - 2015-04-01
    • Milestone: PMD-5.3.0 --> PMD-5.3.1
     
  • Andreas Dangel

    Andreas Dangel - 2015-04-20
    • Milestone: PMD-5.3.1 --> PMD-5.4.0
     
  • Andreas Dangel

    Andreas Dangel - 2015-10-04
    • Milestone: PMD-5.4.0 --> PMD-5.4.1
    • Ruleset / Rule: -->
     
  • Andreas Dangel

    Andreas Dangel - 2015-12-04
    • Milestone: PMD-5.4.1 --> PMD-5.5.0
     
  • Andreas Dangel

    Andreas Dangel - 2016-06-25
    • Milestone: PMD-5.5.0 --> New Tickets
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.