Fix statement cast in UselessOverridingMethodRule class.
Summary: Now using the parent Node class to avoid the ClassCastException. Test Plan: Added new test for the modified class. Run tests Reviewers: jmsotuyo Reviewed By: jmsotuyo Differential Revision: http://ph.monits.com/D12213
This commit is contained in:
@ -130,7 +130,7 @@ public class UselessOverridingMethodRule extends AbstractJavaRule {
|
|||||||
return super.visit(node, data);
|
return super.visit(node, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTStatement statement = (ASTStatement) block.jjtGetChild(0).jjtGetChild(0);
|
Node statement = block.jjtGetChild(0).jjtGetChild(0);
|
||||||
if (statement.jjtGetChild(0).jjtGetNumChildren() == 0) {
|
if (statement.jjtGetChild(0).jjtGetNumChildren() == 0) {
|
||||||
return data; // skips empty return statements
|
return data; // skips empty return statements
|
||||||
}
|
}
|
||||||
|
@ -373,5 +373,28 @@ public class Example extends PersistentObject {
|
|||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
<test-code>
|
||||||
|
<description><![CDATA[
|
||||||
|
ClassCastException in statement cast
|
||||||
|
]]></description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
import java.util.Comparator;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class AnonymousClassConstructor {
|
||||||
|
|
||||||
|
public void method() {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
final Comparator<Long> comparator = new Comparator<Long>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(@Nonnull Long o1, @Nonnull Long o2) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
</test-data>
|
</test-data>
|
Reference in New Issue
Block a user