#336 usage.UnusedPrivateMethod gives false positive

release_4.0
closed
nobody
usage (27)
5
2012-10-10
2005-06-17
Tracey
No

The usage.UnusedPrivateMethod checkstyle check
gives a false positive on the 'assertMethod' in the
following scenario:

i.e.

public class Foo {
private Form form = new Form();

public void callingMethod() {
      assertMethod(form.getCollection());
}

private void assertMethod(Collection collection) {
}

}

public class Form {
public Collection getCollection() {
return Collections.EMPTY_LIST;
}
}

It is only when we delegate to another object to retrieve
the parameter to the method that this check fails. For
Example, the following works o.k.

public class Foo {
public void callingMethod() {
assertMethod(getCollection());
}

private void assertMethod(Collection collection) {
}

public Collection getCollection() {
return Collections.EMPTY_LIST;
}

}

Discussion