abapOpenChecks
abapOpenChecks copied to clipboard
IF in IF - False Positive
The following code:-

Generates the following error:-

Unless I am missing something obvious, if the IF/ENDIF block in the middle contains an ELSE statement then the code cannot be reduced, unless you repeat the outer logical expression in the lines in the IF/ELSE/ENDIF construct.
agree, pull requests welcome
works in abaplint,

I think a small change at Check_01 -> Method contains_else to also look for else-if branch might help.
- Unit test results after adding a new scenario

Adding below code:
IF lo_structure->get_type( ) = zcl_aoc_scan=>gc_structure_statement-else or lo_structure->get_type( ) = zcl_aoc_scan=>gc_structure_statement-elseif .
All test pass post-changes.
Let me know if this works, I will add PR.
@Dwivedirahul44 suggest just go ahead and opening the PR, its easier to read the code, plus it can be tested
PR added.