Sorting already exists before deletion

Template for a good false-positive report, formatted with Markdown:

  • versions used (SonarQube, Scanner, language analyzer)
    Version:9.0.1.46107
    Language analyzer:abap

  • minimal code sample to reproduce (with analysis parameter, and potential instructions to compile).

sort me->t_charamap by prog_chara ricefno descending.
delete adjacent duplicates from me->t_charamap comparing prog_chara.

abap:S1673 Still report bug

Wrap code around triple quote ``` for proper formatting

  sort gt_item by gjahr   belnr buzei.
  gt_outitab[] = gt_item[].
  delete adjacent duplicates from gt_outitab comparing gjahr   belnr.

This style will also give false positives

Hello @agate

I know it’s an old topic, I just stumbled into it and decided to have a closer look.

To me, there are two different problems.

The first one is when you access a table with reference. It is indeed not supported, I created a ticket to fix this: SONARABAP-441.

For the second code sample, the implementation of the rule is not following the “flow” of variables, it is not able to track the fact that gt_outitab was sorted before thanks to gt_item. I’m afraid we can not do much currently, as supporting this use case would require complex logic. I suggest marking this issue as False positive.

Best,
Quentin