logo       

[ checkstyle-Feature Requests-1787303 ] New Test: Shadowing a field: msg#00260

Subject: [ checkstyle-Feature Requests-1787303 ] New Test: Shadowing a field
Feature Requests item #1787303, was opened at 2007-09-03 19:39
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397081&aid=1787303&group_id=29721

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Check
Group: None
Status: Open
Priority: 5
Private: No
Submitted By: Benoit Xhenseval (benoitx)
Assigned to: Nobody/Anonymous (nobody)
Summary: New Test: Shadowing a field

Initial Comment:
Hi *,

I would like to suggest a new test to detect the following basic pattern.

I believe that in most case this is a bug (especially after a big re-factoring).

Both TestA and TestB define methods get/setField, which is fine but they also 
define
the field itself.  This is unlikely to be correct.

I'd love to see this test added to the tool

Thanks for considering it

Regards from London,

Benoit
---------------------


public class TestA {
    private int field;

    public int getField() {
        return field;
    }

    public void setField(int field) {
        this.field = field;
    }    
}

public class TestB extends TestA {
    private int field; // this should be flagged!

    @Override
    public int getField() {
        return field;
    }

    @Override
    public void setField(int field) {
        this.field = field;
    }    
}


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397081&aid=1787303&group_id=29721

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/


<Prev in Thread] Current Thread [Next in Thread>