rspec/rules/S1574/cobol/rule.adoc

49 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
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
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,cobol]
2021-04-28 16:49:39 +02:00
----
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
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,cobol]
2021-04-28 16:49:39 +02:00
----
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[]