2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2020-06-30 10:16:44 +02:00
|
|
|
Procedures with excessive parameters are difficult to use, as one needs to figure out what each parameter is.
|
2021-02-02 15:02:10 +01:00
|
|
|
|
2020-06-30 10:16:44 +02:00
|
|
|
In many cases, the procedure can either be split into several smaller ones, or a better data structure can be found.
|
2021-02-02 15:02:10 +01:00
|
|
|
|
2020-06-30 10:16:44 +02:00
|
|
|
This rule verifies that each procedure has at most the given number of parameters.
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2020-06-30 10:16:44 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,pli]
|
2020-06-30 10:16:44 +02:00
|
|
|
----
|
|
|
|
foo: proc options(main);
|
|
|
|
declare myArray (9) fixed decimal init (1, 2, 3, 4, 5, 6, 7, 8, 9);
|
|
|
|
|
|
|
|
put list (mySum(myArray(1), myArray(2), myArray(3), myArray(4), myArray(5), myArray(6), myArray(7), myArray(8), myArray(9)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
mySum: proc (a1, a2, a3, a4, a5, a6, a7, a8, a9) returns (fixed decimal); /* Non-Compliant - too many parameters */
|
|
|
|
declare (a1, a2, a3, a4, a5, a6, a7, a8, a9) fixed decimal;
|
|
|
|
|
|
|
|
return (a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9);
|
|
|
|
end;
|
|
|
|
----
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2020-06-30 10:16:44 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,pli]
|
2020-06-30 10:16:44 +02:00
|
|
|
----
|
|
|
|
foo: proc options(main);
|
|
|
|
declare myArray (9) fixed decimal init (1, 2, 3, 4, 5, 6, 7, 8, 9);
|
|
|
|
|
|
|
|
put list (sum(myArray)); /* Compliant - uses the built-in sum() function which works on an array */
|
|
|
|
end;
|
|
|
|
----
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
|
|
|
include::parameters.adoc[]
|
|
|
|
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|