rspec/rules/S1574/cobol/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
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.
2023-05-25 14:18:12 +02:00

49 lines
1.2 KiB
Plaintext

== Why is this an issue?
Initializing a data item with a value of the wrong type will lead to runtime errors. The rule checks that numeric data items are not initialized with alphanumeric/alphabetic values and that alphanumeric /alphabetic data items are not initialized with numeric values.
=== Noncompliant code example
[source,cobol]
----
WORKING-STORAGE SECTION.
EJECT
01 TAB-POS.
02 FILLER PIC A(14) VALUE 0. *> Noncompliant
02 FILLER PIC 9(14) VALUE 'ASDFJKL;QWERTY'. *> Noncompliant
01 MYGROUP PIC 9(1).
88 X VALUE 1,2.
88 Y VALUE 3, "BLUE". *> Noncompliant; BLUE is alphanumeric
----
=== Compliant solution
[source,cobol]
----
WORKING-STORAGE SECTION.
EJECT
01 TAB-POS.
02 FILLER PIC A(14) VALUE 'ASDFJKL;QWERTY'.
02 FILLER PIC 9(14) VALUE 0.
01 MYGROUP PIC 9(1).
88 X VALUE 1,2.
88 Y VALUE 3, 4.
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
(An alphanumeric|A numeric) data item should not be initialized with (a numeric|an alphanumeric) value.
endif::env-github,rspecator-view[]