Menu

#1261 False positive "Avoid unused private methods" with Generics

PMD-5.2.1
closed
None
PMD
3-Major
Bug
5.1.3
2014-11-03
2014-09-13
No

Similar to closed (but not really) https://sourceforge.net/p/pmd/bugs/1156/, and not related to subclass as https://sourceforge.net/p/pmd/bugs/1257/
False positive "Avoid unused private methods such as 'getPrivate(Object)'", with the very simple code :

public class TestPrivate<T> {
    protected Object getProtected(final T bean) {
        return getPrivate(bean);
    }
    private Object getPrivate(final Object bean) {
        return bean;
    }
}

Discussion

  • Fabrice Daugan

    Fabrice Daugan - 2014-09-13

    Test class is provided

     
  • Andreas Dangel

    Andreas Dangel - 2014-10-20
    • status: open --> in-progress
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-next
     
  • Andreas Dangel

    Andreas Dangel - 2014-10-20

    This will be fixed with the next release (5.2.1).

     
  • James Jamieson

    James Jamieson - 2014-10-24

    This looks to be causing some additional false positives now though as well. setTotals is flagged as unused, but that is not true.

     public <T extends Ledgerable, X extends Ledgerable>  void createLedgerAndChangeHistory(T oldObject, X updatedObject, boolean isChildLedgerEntry) throws ServiceException  {
            LedgerEntry entry = new LedgerEntry();
    
        try {
            if (oldObject instanceof BudgetPackage || oldObject instanceof SpiEntity) {
            setTotals(oldObject);
        }
    
        // do other stuff
    
        } catch (ServiceException e) {
    
        }
    
    }
    
    }
    
    private <X extends Ledgerable> void setTotals(X ledgerable) throws ServiceException {
    
    // do stuff
    }
    
     
  • Andreas Dangel

    Andreas Dangel - 2014-11-03
    • status: in-progress --> closed
     

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.