#470 New Test: Shadowing a field

Future
closed
nobody
Check (274)
5
2016-02-27
2007-09-03
No

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;
}

}

Discussion

  • Roman Ivanov

    Roman Ivanov - 2016-02-27
    • status: open --> closed
    • Group: --> Future
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks