Skip to content

Remove the self-reference me->: Does not work in interface methods #41

Closed

Description

@ConjuringCoffee

Hi Jörg-Michael, the self-reference me-> is not removed in interface methods.

Here's an example I re-created using local objects:

INTERFACE lif_test.
  METHODS from_interface.
ENDINTERFACE.


CLASS lcl_test DEFINITION CREATE PUBLIC.

  PUBLIC SECTION.
    INTERFACES lif_test.

  PROTECTED SECTION.

  PRIVATE SECTION.
    DATA mv_value TYPE i.

    METHODS in_class.
ENDCLASS.


CLASS lcl_test IMPLEMENTATION.
  METHOD lif_test~from_interface.
    me->mv_value = 1.
  ENDMETHOD.

  METHOD in_class.
    me->mv_value = 1.
  ENDMETHOD.

ENDCLASS.

Here's the result:
image

Activity

  1. jmgrassau commented on Jun 2, 2023

    @jmgrassau
    Member

    Hi ConjuringCoffee,

    generally, ABAP cleaner can only remove "me->" if the method signature is known – otherwise, it could not be sure in your example whether mv_value is both an attribute and at the same time an exporting parameter; in such a case, me-> would of course have to be kept in order to refer to the attribute (not the parameter).

    That's why this rule usually does not work on interface methods, where the signature is usually "out of sight". Admittedly, though, that's not the case for local interfaces as in your example – so the rule could indeed be enhanced to process these cases!

    Kind regards,
    Jörg-Michael

  2. ConjuringCoffee commented on Jun 2, 2023

    @ConjuringCoffee
    ContributorAuthor

    Hmm, I did not consider that. That's unfortunate - thanks for the explanation!

  3. ConjuringCoffee commented on Jun 2, 2023

    @ConjuringCoffee
    ContributorAuthor

    I suggest adding this to the documentation of the rule. I just noticed that this limitation also impacts attributes inherited from another global class.

  4. self-assigned this
    on Jun 10, 2023
  5. jmgrassau commented on Jun 10, 2023

    @jmgrassau
    Member

    Hi ConjuringCoffee,

    I now added some documentation:

    image

    Also, local interfaces are now correctly considered, including aliases and "cascading" cases (interfaces implementing other interfaces and defining aliases for them etc.):

    image

    Kind regards,
    Jörg-Michael

  6. jmgrassau commented on Jun 12, 2023

    @jmgrassau
    Member

    Hi ConjuringCoffee,

    as mentioned before, the perfect solution is unfortunately not possible here as long as we do not introduce backend calls to ABAP cleaner; however, I think this is as good as it gets for now!

    Kind regards,
    Jörg-Michael

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

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions