Menu

#900 PositionLiteralsFirstInComparison

open
nobody
None
5
2012-10-07
2009-11-10
Z Jacobson
No

This rule seems like it should only apply to String, based on the error message. But it complains about this code:

boolean showPMDbug(Integer a, List<integer> b)
{
return a.equals(b.get(0));
}</integer>

This does not:
boolean showPMDbug(Integer a, List<integer> b)
{
return b.get(0).equals(a);
}</integer>

Discussion

  • Z Jacobson

    Z Jacobson - 2009-11-10

    I am using pmd-maven-plugin version 2.2 to run PMD.

     
  • Romain PELISSE

    Romain PELISSE - 2010-01-23

    Seems to be no file patch nor solution proposal, more like a but report to me...

     
  • Z Jacobson

    Z Jacobson - 2010-01-23

    This is indeed a bug report. But maybe it's just a documentation issue. According to the documentation here (http://pmd.sourceforge.net/rules/design.html), this should apply to String comparisons.

    Is this rule being triggered because the Integer parameter may be null? Maybe this rule is just misnamed if it's tryig to detect potential NullPointerExceptions.

     

Log in to post a comment.