-
Notifications
You must be signed in to change notification settings - Fork 53
Feature request: Remove unnecessary CLEAR
after variable definition
#61
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
CLEAR
after variable definitionCLEAR
after variable definition
Hi ConjuringCoffee, that makes sense, although I think I haven't seen too many of those, at least with CLEAR being right after the declarations. And I assume you don't mean CLEAR further down the method? That's also unnecessary sometimes, but could be intended as a form of safeguarding in the sense of "from here we need to start with an initial value, whatever we may do with this variable in the above blocks (possibly at a later point in time)". However, what might be included (optionally) in such a rule is removing Kind regards, |
I unfortunately see this quite often in legacy code. 😅
I agree, it would be better to only apply the action to |
I see this a lot too. I think people just want to feel safe, or don't know that local variables are always empty at the beginning even if the method/form is called multiple times. I also see |
Hi ConjuringCoffee and Mehmet, as mentioned in more detail in #111, this new cleanup rule "Remove needless CLEAR" is now available with version 1.9.0! In my sample code, I indeed found quite a number of places with such CLEAR statements esp. at method start. In one case, there were approx. 20 DATA lines, followed by approx. 10 CLEARs of the variables that were just declared! And yes, with respect to method start, the rule only deletes (or adds a TODO comment for) CLEAR of local variables that is found before any other executable statement, except for ASSERT (actually I forgot BREAK-POINT and LOG-POINT statements, those are acceptable before a to-be-removed CLEAR as well – will add that with the next release). Kind regards, |
Hi Jörg-Michael, I'd like to request an action to remove unnecessary
CLEAR
statements after a variable has been defined. There is no reason why you should clear a variable you just defined if you're not in some kind of loop.Example:
Expected result:
The text was updated successfully, but these errors were encountered: