
## Review A dedicated reviewer checked the rule description successfully for: - [x] logical errors and incorrect information - [x] information gaps and missing content - [x] text style and tone - [x] PR summary and labels follow [the guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
57 lines
1.2 KiB
Plaintext
57 lines
1.2 KiB
Plaintext
include::../description.adoc[]
|
|
|
|
include::../how-to-fix-it.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,cobol,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
DATA DIVISION.
|
|
WORKING-STORAGE SECTION.
|
|
01 WS-COUNT PIC 9(1) VALUE 0.
|
|
PROCEDURE DIVISION.
|
|
A-PARA.
|
|
PERFORM B-PARA UNTIL WS-COUNT=5 *> Noncompliant - 5 is a magic number
|
|
STOP RUN.
|
|
|
|
B-PARA.
|
|
DISPLAY "Count:"WS-COUNT.
|
|
ADD 1 TO WS-COUNT.
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,cobol,diff-id=1,diff-type=compliant]
|
|
----
|
|
DATA DIVISION.
|
|
WORKING-STORAGE SECTION.
|
|
01 WS-COUNT PIC 9(1) VALUE 0.
|
|
01 WS-NUMBER-OF-CYCLES PIC 9(1) VALUE 5.
|
|
PROCEDURE DIVISION.
|
|
A-PARA.
|
|
PERFORM B-PARA UNTIL WS-COUNT=WS-NUMBER-OF-CYCLES *> Compliant
|
|
STOP RUN.
|
|
|
|
B-PARA.
|
|
DISPLAY "Count:"WS-COUNT.
|
|
ADD 1 TO WS-COUNT. *> Compliant - 1 is not considered a magic number
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|