IG: Parameter Hides Member Variable

I had the following case


class foo extends bar
{
public foo(int a, SSAttributes attr, String c, float d)
{
super(a,attr,c,d);
attr.addListener(this);
}
}

In the super class I have:

class bar
{
public foo(int a, SSAttributes attr, String c, float d)
{
this.a = a;
this.attr = (SSAttributes) attr.clone();
this.c = c;
this.d = d;
}
}

I had the "Ignore for constructors checked, and I missed the obvious bug with the clone.

The question is whether or not this test could be refined so that the common idioms like straight assignent and calling the superclass constructor) could be ignored, while the more subtle issues (like calling methods on the passed in object) could be flagged as a possible bug.

Perhaps its too complicated, but it would have saved me a couple of hours :)

Mike

1 comment
Comment actions Permalink

Or, after thinking about it, perhaps the real issue is calling methods or assigning values to variables passed into the constructor (or setters). That does seem somewhat dubious.

Mike

0

Please sign in to leave a comment.