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

Check for self-references behaves inconsistently #567

Open
bjoern-jueliger-sap opened this issue Jul 15, 2022 · 0 comments
Open

Check for self-references behaves inconsistently #567

bjoern-jueliger-sap opened this issue Jul 15, 2022 · 0 comments
Labels
enhancement An enhancement or scope enhancement

Comments

@bjoern-jueliger-sap
Copy link
Member

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).

@bjoern-jueliger-sap bjoern-jueliger-sap added the enhancement An enhancement or scope enhancement label Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or scope enhancement
Projects
None yet
Development

No branches or pull requests

1 participant