Single use expression temporary

 home quick fix  example  edit

single_use_expression_temp

Description

Finds DATA(a) = . directly followed by x = a., assign the expression to x

Extended Information

Reports DATA(a) = . when all of the following hold:

* a is a local variable of a METHOD, FORM or FUNCTION, with no other reference than the next statement,
which is x = a., in the same block
* the result type of the expression does not depend on the target: no arithmetic or bit operators, no unary
minus, no numeric functions like abs( ) or trunc( ) whose type follows the argument, no CONV or EXACT,
no # type inference at the top. String templates, && concatenations, literals, method calls, NEW, CAST,
constructor expressions with explicit type and table expressions are fine
* VALUE, CORRESPONDING, COND, SWITCH, REDUCE and FILTER can build their result directly in the target,
they are only inlined into a new variable, or a local variable that they do not read and whose address
is never taken
* plain data objects are left for unnecessary_copy

Objects with syntax errors, macros or unknown statements are skipped, as are procedures with dynamic code,
INCLUDE, test seams, enhancements or native SQL.

The quick fix deletes the declaration and writes x = . No release requirement.

Default Configuration

Hover to see descriptions, Ctrl+Space for suggestions

Examples