rspec/rules/S3923/cobol/rule.adoc
2022-02-04 16:28:24 +00:00

50 lines
1.1 KiB
Plaintext

Having all branches in an ``++EVALUATE++`` or ``++IF++`` chain with the same implementation is an error. Either a copy-paste error was made and something different should be executed, or there shouldn't be an ``++EVALUATE++``/``++IF++`` chain at all.
== Noncompliant Code Example
[source,cobol]
----
EVALUATE X *> Noncompliant
WHEN 1
PERFORM SECTION1
WHEN OTHER
PERFORM SECTION1
END-EVALUATE.
IF X = 1 THEN *> Noncompliant
PERFORM SECTION1
ELSE
PERFORM SECTION1
END-IF.
----
== Exceptions
Note that this rule does not apply to ``++IF++`` chains without ``++ELSE++``-s, or to ``++EVALUATE++``-s without ``++WHEN OTHER++`` clauses.
----
IF X = 1 THEN *> //no issue, this could have been done on purpose to make the code more readable
PERFORM SECTION1
ELSE-IF X = 2 THEN
PERFORM SECTION1
END-IF.
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]