Overriding a method just to call the same method from the super class without performing any other actions is useless and misleading. The only time
this is justified is in final
overriding methods, where the effect is to lock in the parent class behavior. This rule ignores such
overrides of equals
, hashCode
and toString
.
Noncompliant code example
public void doSomething() {
super.doSomething();
}
@Override
public boolean isLegal(Action action) {
return super.isLegal(action);
}
Compliant solution
@Override
public boolean isLegal(Action action) { // Compliant - not simply forwarding the call
return super.isLegal(new Action(/* ... */));
}
@Id
@Override
public int getId() { // Compliant - there is annotation different from @Override
return super.getId();
}