Skip to content

"Delete unused variables" rule deletes variable which used in macros. #43

Closed

Description

@thebestabapdeveloper

"Delete unused variables" rule deletes variable which used in macros.

For example:

In include f01
DATA: lv_tuna TYPE developer.

In include m01
DEFINE xxx.
&1 = lv_tuna + 'xxx'.
END-OF-DEFINITION.

when formatting include f01, it deletes the definition in include f01, so it cannot be activated.

Activity

  1. thebestabapdeveloper commented on Jun 5, 2023

    @thebestabapdeveloper
    Author

    I temporarily chose the option to 'comment out with "' for local variables that are never used.

  2. added
    documentationImprovements or additions to documentation
    bugSomething isn't working
    on Jun 5, 2023
  3. jmgrassau commented on Jun 5, 2023

    @jmgrassau
    Member

    Hi thebestabapdeveloper :-),

    thank you very much for reporting this. Actually, this is a limitation of ABAP cleaner: the tool only works on the code document provided to it, without doing further backend calls. This usually works fine for local variables, but macros are indeed an exception that can't be considered here, especially if the macro definition is 'out of sight'.

    I shall therefore restrict the "Delete unused variables" rule to only work on methods that do NOT make use of macros (hopefully you won't find too much usage of macros in the code anyway…)

    Kind regards,
    Jörg-Michael

  4. self-assigned this
    on Jun 5, 2023
  5. jmgrassau commented on Jun 6, 2023

    @jmgrassau
    Member

    Hi,

    this issue should now be fixed in the freshly released version 1.3.0, meaning that the rule "Delete unused variables" (as well as "Use FINAL form immutable variables") will now simply skip methods in which macros are used hopefully adding another motivation to replace macros with other constructs :-) Thanks again for pointing this out!

    Kind regards,
    Jörg-Michael

  6. thebestabapdeveloper commented on Aug 14, 2023

    @thebestabapdeveloper
    Author

    Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions