rspec/rules/S2033/rpg/rule.adoc

55 lines
1.3 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Because library names could change from environment to environment, they should never be hard-coded in a program. Instead, you should use a variable to specify the library name and set that variable with data external to the program.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,rpg]
2021-04-28 16:49:39 +02:00
----
CLRPFM FILE(XPJLIB/FILE01)
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,rpg]
2021-04-28 16:49:39 +02:00
----
CHGVAR VAR(&LIB01) VALUE(&PREFIX *CAT 'LIB')
CLRPFM FILE(&LIB01/FILE01)
----
=== Exceptions
2021-04-28 16:49:39 +02:00
Hard-coding references to QTEMP, which is a temporary library, is allowed.
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use a variable for the library name and set it with data external to the program.
'''
== Comments And Links
(visible only on this page)
=== on 12 Oct 2014, 16:51:40 Freddy Mallet wrote:
Just a feeling @Ann, but I would decrease the severity to Major and would not activate this rule by default.
=== on 14 Oct 2014, 14:48:34 Ann Campbell wrote:
\[~freddy.mallet] breaking this rule can (will) cause runtime failures, which is why I've made it critical. I set it to on by default because I've had 2 different companies ask me for the rule (and the second actually helped me specify it).
=== on 14 Oct 2014, 21:04:33 Freddy Mallet wrote:
OK
endif::env-github,rspecator-view[]