SAP / code-pal-for-abap

code pal for ABAP is a highly configurable engine, fully integrated into the ABAP development framework ensuring Cloud’s built-in quality.
Apache License 2.0
348 stars 65 forks source link

Class Method called on instance #330

Open estevao-schultz-neto-SAP opened 3 years ago

estevao-schultz-neto-SAP commented 3 years ago

Such a check is known from other programming languages (Java, C# etc.), and it would be great to have it in ABAP, too: Static methods should only be called on the class (=>), NOT on an instance (->), because if someone calls a static method on an instance, they probably don't know what is really happening. (I just discovered such a case in our code which was copied a lot to other places; a check would have helped to discover this: CL_FARR_TD_UTILITY_FACTORY=>CREATE_DOUBLE( )->INJECT_ITSELF( … ) is called, but INJECT_ITSELF is a class-method.) Grassau, Joerg-Michael

lucasborin commented 3 years ago

Ref https://github.com/SAP/styleguides/issues/210 and https://github.com/SAP/styleguides/pull/224