You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that the "Prefix is current class" check generates a finding even when a static method is called from within an instance method and the class name precedes the call. However, according to the Clean ABAP guidelines, it's recommended to qualify such calls with the class name even from within instance methods:
"However, within an instance method, even when calling a static method of the same class, you should still qualify the call with the class name."
I suggest modifying the check so that it doesn't flag such cases as findings when the call is made from an instance method. Here is an example to illustrate:
CLASSzcl_test_something DEFINITION PUBLIC FINAL CREATE PUBLIC .
PUBLIC SECTION.
CLASS-METHODS test1.
METHODS test2.
ENDCLASS.
CLASSzcl_test_something IMPLEMENTATION.
METHODtest1.
zcl_test_something=>test1( ). "Should create a finding
test1( ).
ENDMETHOD.
METHODtest2.
zcl_test_something=>test1( ). "Should not create a finding
test2( ).
ENDMETHOD.
ENDCLASS.
Best regards,
Ben
The text was updated successfully, but these errors were encountered:
Hello,
I've noticed that the "Prefix is current class" check generates a finding even when a static method is called from within an instance method and the class name precedes the call. However, according to the Clean ABAP guidelines, it's recommended to qualify such calls with the class name even from within instance methods:
"However, within an instance method, even when calling a static method of the same class, you should still qualify the call with the class name."
Reference: Clean ABAP Guide - Don't call static methods through instance variables
I suggest modifying the check so that it doesn't flag such cases as findings when the call is made from an instance method. Here is an example to illustrate:
Best regards,
Ben
The text was updated successfully, but these errors were encountered: