rspec/rules/S1608/rpg/rule.adoc

59 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Initializing an alphanumeric field with the literal character ``++' '++``, ``++'1'++``, or ``++'0'++`` has the same effect as using the equivalent figurative constant ``++*BLANK++``, ``++*ON++``, or ``++*OFF++``, but the constant version removes ambiguity and makes the code more readable.
=== 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
----
C MOVE ' ' FLD1
----
2022-02-04 17:28:24 +01:00
[source,rpg]
2021-04-28 16:49:39 +02:00
----
/free
fld1 = ' ';
/end-free
----
=== 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
----
C MOVE *BLANK FLD1
----
2022-02-04 17:28:24 +01:00
[source,rpg]
2021-04-28 16:49:39 +02:00
----
/free
fld1 = *BLANK;
/end-free
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Replace this string literal 'x' literal with YYY
'''
== Comments And Links
(visible only on this page)
=== on 4 Mar 2014, 16:36:23 Ann Campbell wrote:
updated spec per email from customer, which does not use empty string:
the ' ' literal is not to be used to represent *BLANK
endif::env-github,rspecator-view[]