squid:S1161 "@Override" should be used on overriding and implementing methods

As title of rule suggest - rule should be fired for

  • overriding a methods - this works
  • implementing a method of interface - this not works

I know, there are many opinion about it, but I think that using @Override for implemented method is good practice. eg. when we remove method from interface we will know about it.

Maybe we can achieve this by parameter on rule or new rule.

Hello Slawomir,

The rule was initially implemented to also raise issues on implementing methods from interfaces.

From our experience over the last few years, however, we realized that this approach was generating way too much noise. We received numerous feedback that the rules was raising issues on way too many cases, making it painful to follow and frustrating. For this reason, the rule is now only focusing on overriding actual method implementations.

As an example of controversial/noisy case:

new Thread(new Runnable() {
  public void run() { //  <- using the @Override annotation is totally overkill here
    // ...
  }
}

As you mentioned, today the rule is consequently a bit less effective. We let the decision to end users to use it or not.
Regarding parameterizing the rule or a new rule, these are solutions we don’t want to go on for the moment, except if we get massive push from community.

Cheers,
Michael