Suspicious loop
suspicious_loop
Description
Finds WHILE loops whose condition the loop body never changes
Extended Information
Option unchangedCondition: reports a WHILE loop when the loop body cannot change its condition
after the first iteration. Then the loop runs zero times, once or forever.
The condition may read local variables of the METHOD, FORM or FUNCTION, constants, builtin functions
like lines( ), and attributes and parameters without ->. Each local variable in it is either
* not written in the loop body, or
* only written by var = source. directly in the loop body, not in a nested block, where the source is
the same in every iteration: no method calls, field symbols or ->*, and it only reads constants,
local variables that the loop body does not write, and other data that the loop body does not write.
Attributes and parameters in the condition must not be written in the loop body either.
When the condition or a source reads data that is not local, the loop body must not call methods,
functions or forms, except instance methods via local reference variables, and must not write via
field symbols or ->*. A source that reads local->attribute also needs that the loop body calls no
method via that local.
Not reported: conditions with system fields like sy-subrc, field symbols, -> or method calls, local
variables whose address is taken, loop bodies with EXIT, RETURN, RAISE, MESSAGE, LEAVE, SUBMIT, STOP or
REJECT, and, when the condition variables are written, loop bodies with CONTINUE or CHECK.
Objects with syntax errors, macros or unknown statements are skipped, as are procedures with dynamic code,
INCLUDE, test seams, enhancements or native SQL.