org.sonar.l10n.java.rules.squid.S1185.html Maven / Gradle / Ivy
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();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy