rspec/rules/S1871/rpg/exceptions.adoc
2023-10-24 12:02:02 +00:00

27 lines
828 B
Plaintext

=== Exceptions
Blocks in an `if` chain or `select` statement that contain a single line of code are ignored.
[source,rpg]
----
if (a >= 0 and a < 10);
doTheThing();
elseif (a >= 10 and a < 20);
doTheOtherThing();
elseif (a >= 20 and a < 50);
doTheThing(); //no issue, usually this is done on purpose to increase the readability
else;
doTheRest();
endif;
----
But this exception does not apply to `if` chains without `else`-s, or to `select`-s without `other` clauses when all branches have the same single line of code. In the case of `if` chains with `else`-s, or of `select`-s with `other` clauses, rule S3923 raises a bug.
[source,rpg]
----
if (a >= 0 and a < 10);
doTheThing();
elseif (a >= 20 and a < 50);
doTheThing(); //Noncompliant, this might have been done on purpose but probably not
endif;
----