abap-cleaner icon indicating copy to clipboard operation
abap-cleaner copied to clipboard

Unused variables in iteration expressions

Open Segurega opened this issue 2 years ago • 1 comments

it would be great if the tool would issue warnings in iteration expressions if variable is assigned but never used. For example:

    DATA: lt_where_clause TYPE string_table,
          lv_where_clause TYPE string.

    lt_where_clause = VALUE string_table( ( | ACDOCA~RBUKRS EQ @MV_BUKRS| )
                                          ( |AND ACDOCA~GJAHR EQ @MV_GJAHR| ) ).
    lv_where_clause = REDUCE #( INIT str TYPE string FOR lv_where IN lt_where_clause NEXT str = str && ` ` ).

Expecting:

     " TODO: variable "lv_where" is assigned but never used;
     lv_where_clause = REDUCE #( INIT str TYPE string FOR lv_where IN lt_where_clause NEXT str = str && ` ` ).

Segurega avatar Oct 13 '23 11:10 Segurega

Hi Segurega,

good point, thanks for the example! I will have to check how this could be implemented, given the limited scope of these variables in iteration expressions.

Kind regards, Jörg-Michael

jmgrassau avatar Oct 18 '23 09:10 jmgrassau