You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
variable is assigned but never used not working correctly #331
CLASS zcl_demo_01 DEFINITION
PUBLIC FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS replace_text_in
IMPORTING
mailtext TYPE string
with TYPE clike
if TYPE clike
text TYPE clike OPTIONAL
RETURNING
VALUE(r_result) TYPE string.
PRIVATE SECTION.
TYPES: BEGIN OF _changed_parts,
one TYPE abap_bool,
two TYPE abap_bool,
three TYPE abap_bool,
END OF _changed_parts.
DATA changed_parts TYPE _changed_parts.
ENDCLASS.
CLASS zcl_demo_01 IMPLEMENTATION.
METHOD replace_text_in.
ASSIGN COMPONENT if OF STRUCTURE changed_parts TO FIELD-SYMBOL(<field>).
IF sy-subrc > 0.
RETURN.
ENDIF.
" TODO: variable is assigned but never used (ABAP cleaner)
DATA(findstr) = |${ if }%|.
r_result = mailtext.
DATA(replacestr) = |<p>{ with }{ COND #( WHEN text IS SUPPLIED THEN |: <b>{ text }</b>| ELSE `` ) }</p>|.
IF <field> IS NOT INITIAL.
REPLACE findstr WITH replacestr INTO r_result.
ELSE.
REPLACE findstr WITH `` INTO r_result.
ENDIF.
ENDMETHOD.
ENDCLASS.
ABAP cleaner thinks that the variable findstr is not used, but it is by REPLACE.
Activity
jmgrassau commentedon Jun 26, 2024
Hi Enno,
thanks for reporting this bug! If you activate the menu "Highlight / Write Positions", you can see that this happened because ABAP cleaner misinterpreted the obsolete syntax of REPLACE substring WITH new INTO dobj:
The write position really is
ev_result, and after fixing that, the issue will not come up anymore in the next release:Kind regards,
Jörg-Michael
Ennowulff commentedon Jun 26, 2024
Thanks for fast fixing of this glitch, @jmgrassau ! ❤️
fix UnusedVariablesRule for obsolete REPLACE ... INTO (SAP#331)
fix UnusedVariablesRule for obsolete REPLACE ... INTO (#331)
jmgrassau commentedon Jul 8, 2024
Hi Enno,
thanks again for reporting this bug – this should now be fixed with version 1.18.0, which was just released!
Kind regards,
Jörg-Michael