larshp / abapOpenChecks

Open source checks for SAP Code Inspector / ABAP Test Cockpit
https://docs.abapopenchecks.org
MIT License
270 stars 79 forks source link

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

Closed BiberM closed 2 years ago

BiberM commented 2 years ago

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 wrinting 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 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.

larshp commented 2 years ago

duplicate of https://github.com/larshp/abapOpenChecks/issues/1083, closing