rspec/rules/S3592/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

87 lines
2.3 KiB
Plaintext

== Why is this an issue?
88-level variables, also known as "condition name" variables, represent possible values of the "conditional variables" they're tied to. Because a condition name can be used to test the value of its conditional variable without any other contextual references to the conditional variable being tested, it makes the code easier to understand if the name of the 88-level variable references its conditional variable.
This rule raises an issue when the name of an 88-level variable does not start with the first characters of the name of its conditional variable.
=== Noncompliant code example
With the default minimum of 3:
[source,cobol]
----
01 COLOR PIC X.
88 YELLOW VALUE 'Y'. *> Noncompliant
88 GREEN VALUE 'G'. *> Noncompliant
88 RED VALUE 'R'. *> Noncompliant
* ...
IF GREEN *> What does this mean?
* ...
END-IF
----
=== Compliant solution
[source,cobol]
----
01 COLOR PIC X.
88 COL-YELLOW VALUE 'Y'.
88 COL-GREEN VALUE 'G'.
88 COL-RED VALUE 'R'.
* ...
IF COL-GREEN
* ...
END-IF
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Rename variable "yyy" so that the first n chars are "xxx".
=== Parameters
.minimumChars
****
----
3
----
The number of characters from the beginning of the conditional variable name that the name of the condition name should start with.
****
=== Highlighting
* primary: name in condition name declaration
* secondary: name in conditional variable declaration
'''
== Comments And Links
(visible only on this page)
=== on 21 Dec 2016, 15:32:50 Robert Shawver wrote:
shouldn't the last line of the description read "This rule raises an issue when the *condition name* does not start with the first characters of the name of its conditional variable."? also, will this error be raised if the conditional variable is FILLER, which it can legitimately be?
=== on 3 Jan 2017, 16:18:36 Ann Campbell wrote:
\[~rshawver] I've corrected the last sentence. For the ``++FILLER++`` question, please open a new thread on the https://groups.google.com/forum/?pli=1#!forum/sonarqube[Google Group] because I've got questions, but this is not the right venue for an extended conversation.
And thanks for the correction!
endif::env-github,rspecator-view[]