Check for self-references behaves inconsistently
Nobody has claimed this yet.
- Dominant language
- ABAP
- Stars
- 435
- Forks
- 77
- PR merge metrics
- No merged PRs in 30d
Description
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).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Y_CHECK_SELF_REFERENCE implementation and reproduce the supplied ABAP example with its six me-> references. Compare the check's behavior with the Clean ABAP guidance, including method and attribute references and the possible local-variable aliasing case. Done means the check handles the documented reference forms consistently and covers the relevant aliasing behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100