Menu

#788 BeanMembersShouldSerialize doesn't understand boolean naming

closed
nobody
pmd (543)
5
2012-10-07
2008-07-21
Don Kirkby
No

Bug 962782 seems to have reappeared or still be present in PMD for Eclipse 3.2.4.v200804111600.

This class breaks the rule:
package com.pets;

public class Dog {
private boolean isCute;

/**

 * @return the isCute
 */
public boolean isCute()
{
    return isCute;
}

/**

 * @param isCute the isCute to set
 */
public void setCute(boolean isCute)
{
    this.isCute = isCute;
}

}

This class doesn't break the BeanMembersShouldSerialize rule, but does break BooleanGetMethodName.
package com.pets;

public class Cat {
private boolean isCute;

/**

 * @return the isCute
 */
public boolean getIsCute()
{
    return isCute;
}

/**

 * @param isCute the isCute to set
 */
public void setIsCute(boolean isCute)
{
    this.isCute = isCute;
}

}

Discussion

  • Xavier Le Vourch

    Logged In: YES
    user_id=1373398
    Originator: NO

    I implemented a fix but I'm not sure it should be changed as the field has the same name as the method and triggers AvoidFieldNameMatchingMethodName. Maybe we should just document the fact that a boolean field is not supposed to start with "is"?

    The original fix for bug 962782 deals with the field named "cute" instead of "isCute".

     
  • Romain PELISSE

    Romain PELISSE - 2008-12-09

    hum, no answer to Xavier on this one... Set this entry to pending.

     
  • Jan Ruzicka

    Jan Ruzicka - 2009-08-19

    can this issue be be updated to be marked as false positive? Other issues seem to use False + for start of title.

     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 500 days (the time period specified by
    the administrator of this Tracker).

     

Log in to post a comment.

MongoDB Logo MongoDB