abapOpenChecks icon indicating copy to clipboard operation
abapOpenChecks copied to clipboard

ATC Check 040: Doesn't recognize swap of lhs and rhs

Open BiberM opened this issue 3 years ago • 0 comments

Within an IF-Statement left hand side and right hand side can be swapped. So the following statement is a valid handling of SY-SUBRC: IF 0 = sy-subrc. do_something( ). ENDIF.

But the Check 040 does not recognize this. The reason is that it searches for the pattern *<space>SY-SUBRC<space>*. My question is: what was the reason for those spaces? When writting SY-SUBRC at the lhs everything is fine and also if there are more conditions following. Could at least the second space in the pattern be removed?

For most ABAPers this writing style is probably unsual. The colleague finding this told me that he got used to this when studiying C/C++ where there is a difference beween i = 0 and i == 0. In order to avoid forgetting one "=" they type 0 == i when they want a comparison. Forgetting one "=" then gives a syntax error.

BiberM avatar Jul 01 '22 19:07 BiberM