rspec/rules/S3389/rpg/rule.adoc
2022-02-04 16:28:24 +00:00

62 lines
1.2 KiB
Plaintext

The use of ``++options( *nopass )++`` on a parameter makes it optional, so it should always be checked before use.
== Noncompliant Code Example
[source,rpg]
----
DCL-PR VIOLATION1 EXTPGM;
LASTNAME Char(10);
FIRSTNAME Char(10) OPTIONS(*NOPASS:*OMIT);
END-PR;
DCL-PI VIOLATION1;
LASTNAME Char(10);
FIRSTNAME Char(10) OPTIONS(*NOPASS:*OMIT);
END-PI;
dsply FIRSTNAME;
dsply LASTNAME; // Noncompliant; LASTNAME is optional
*inlr = *on;
----
== Compliant Solution
[source,rpg]
----
DCL-PR VIOLATION1 EXTPGM;
LASTNAME Char(10);
FIRSTNAME Char(10) OPTIONS(*NOPASS:*OMIT);
END-PR;
DCL-PI VIOLATION1;
LASTNAME Char(10);
FIRSTNAME Char(10) OPTIONS(*NOPASS:*OMIT);
END-PI;
dsply FIRSTNAME;
IF %PARMS > 1;
dsply LASTNAME;
EndIf;
*inlr = *on;
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]