Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust "Prefix is current class" Check to Exclude Findings for Class Name-Prefixed Static Method Calls from Instance Methods #3289

Open
BenjaminWeisheit opened this issue Apr 5, 2024 · 0 comments

Comments

@BenjaminWeisheit
Copy link

BenjaminWeisheit commented Apr 5, 2024

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:

CLASS zcl_test_something DEFINITION  PUBLIC  FINAL CREATE PUBLIC .
  PUBLIC SECTION.
    CLASS-METHODS test1.
    METHODS test2.
ENDCLASS.

CLASS zcl_test_something IMPLEMENTATION.
  METHOD test1.
    zcl_test_something=>test1( ). "Should create a finding
    test1( ).
  ENDMETHOD.

  METHOD test2.
    zcl_test_something=>test1( ). "Should not create a finding
    test2( ).
  ENDMETHOD.
ENDCLASS.

Best regards,
Ben

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant