
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
78 lines
1.9 KiB
Plaintext
78 lines
1.9 KiB
Plaintext
== Why is this an issue?
|
|
|
|
88-level variables, also known as "condition name" variables, each have a name, a value or set of values, and a "parent" variable. Those parent variables are called "conditional variables".
|
|
|
|
|
|
Each 88-level variable can be seen as a short-cut conditional for testing the value of the parent: ``++IF MY-88++`` will intrinsically return ``++true++`` if the parent value matches ``++MY-88++``'s value, and ``++false++`` if it does not.
|
|
|
|
|
|
Thus, testing a conditional variable against a literal value is redundant and confusing. Just use the 88-levels instead.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,cobol]
|
|
----
|
|
01 COLOR PIC X
|
|
88 YELLOW VALUE 'Y'
|
|
88 GREEN VALUE 'G'
|
|
88 RED VALUE 'R'
|
|
...
|
|
IF COLOR = 'G' *> Noncompliant
|
|
...
|
|
END-IF
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,cobol]
|
|
----
|
|
01 COLOR PIC X
|
|
88 YELLOW VALUE 'Y'
|
|
88 GREEN VALUE 'G'
|
|
88 RED VALUE 'R'
|
|
...
|
|
IF GREEN
|
|
...
|
|
END-IF
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Remove this comparison of "xxx" with "yyy" and simply test "zzz" instead.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
operator and both operands
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 29 Mar 2016, 10:38:01 Pierre-Yves Nicolas wrote:
|
|
\[~ann.campbell.2] I added code samples.
|
|
|
|
The title should be changed to something like: "Variables which have 88-level variables should not be compared with literals".
|
|
|
|
I think the rule should not check only literal strings but also literal numbers.
|
|
|
|
|
|
The official documentations (e.g. http://www.ibm.com/support/knowledgecenter/SS6SG3_5.1.0/com.ibm.entcobol.doc_5.1/PGandLR/ref/rlddeva2.html[IBM]) have some precise names for these "variables":
|
|
|
|
* 88-level variables are called "condition names".
|
|
* variables on which "condition names" are defined are called "conditional variables"
|
|
|
|
However, I'm not sure that developers use these names.
|
|
|
|
endif::env-github,rspecator-view[]
|