-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unused variables potential dangerous behavior #237
Comments
Not sure about how the detection would reliably work? I am now also wondering how it works in ADT (and ATC). DATA: lv_unused_b TYPE string.
DATA(lv_target) = 'LV_UNUSED_' && sy-abcde+1(1).
assign (lv_target) to field-symbol(<test>). Also includes, enhancements and probably many more. Edit: Todo instead of deletion seems better to me, then it doesn't have to be perfect. |
Hi! |
Hi xczar0, thanks for this finding! I agree, it's better to miss a few cases (simply keeping them as they are) than to break things, and as Fabian nicely pointed out, it would be impossible to reliably detect which variable is the target of the dynamic ASSIGN. Therefore, I think it is best to simply deactivate the affected rules ("Report unused parameters", "Delete unused variables", "Use FINAL for immutable variables") for methods that contain such a dynamic ASSIGN. Probably (and hopefully!) this syntax is anyway not used very often… Will be fixed with the next release! Kind regards, |
Hi xczar0, thanks again for pointing this out – version 1.13.1, which was just released, now blocks methods for "Delete unused variables" etc. if a dynamic ASSIGN is found (see details above)! Kind regards, |
Delete unused variables do not take into consideration potential use of dynamically assigned variables.
Code will not analyze that scenario below (simpliest one)
DATA: lv_unused_b TYPE string.
assign ('lv_unused_b') to field-symbol(<test>).
In my opinion it should detect potential dynamic usage of variable and instead of deletion of variable it should add TODO.
I mean - it adds TODO, but for completely different reason - assigned, but not used variable
The text was updated successfully, but these errors were encountered: