Skip to content

Check for self-references behaves inconsistently #567

Open
@bjoern-jueliger-sap

Description

@bjoern-jueliger-sap

Check: Self-reference

The following code has six superfluous me->s, four of which are for method calls, which is what the check claims it detects:

class cl definition.
  public section.
    methods meth_1
      returning value(result) type i.
    methods meth_2
      importing param type i.
    methods do.
  private section.
    data value type i.
endclass.

class cl implementation.

  method do.
    me->meth_1( ).
    data(var_1) = me->meth_1( ).
    call method me->meth_1
      receiving result = data(var_2).
    meth_2( me->meth_1( ) ).
    data(var_3) = me->value.
    meth_2( me->value ).
  endmethod.

  method meth_1.

  endmethod.

  method meth_2.

  endmethod.

endclass.

The current implementation of Y_CHECK_SELF_REFERENCE emits a finding for the first, fourth and sixth occurence of me->. This means that the check does not detect all references that it claims it detects and also that it detects usages of me-> it doesn't claim to detect (the Clean ABAP guide was only recently changed to advise against all usages of me-> and not only for methods).

The check should be reworked to be more consistent (and if it keeps emitting findings for attributes, it also needs to check that there is no aliasing local variable in scope that makes the me-> necessary).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAn enhancement or scope enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions