Jump to content

Topic on Talk:Continuous integration/Codehealth Pipeline/Flow

"Overriding methods should do more than simply call the same method in the super class" doesn't check visibility

2
Daimona Eaytoy (talkcontribs)

See here: the method is redeclared to widen visibility from private to public.

The description on sonarcloud is, as usually, very interesting: > "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."

Welp, sounds like they missed another compliant case.

DKinzler (WMF) (talkcontribs)

There are also cases in which a subclass wants to provide additional guarantees for the behavior of a method, e.g. a getter may return null in the base class, but is guaranteed to not return null in a subclass. We need to override the method in order to declare the contract in a doc block.

I would just disable this rule, it seems "useless and misleading".

Reply to ""Overriding methods should do more than simply call the same method in the super class" doesn't check visibility"