2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-04-28 16:49:39 +02:00
You're allowed to make function calls with positionally-identified parameters or with named parameters. In long parameter lists, explicitly naming your parameters both eliminates the risk of swapping parameter values and makes the call clearer to maintainers.
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
With the default threshold of 3:
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
def coordinateSurpriseParty(self, hostName, guestOfHonor, caterer, invitees, peopleNotToInvite):
# ...
host="John"
guestOfHonor="Fred"
caterer="Barry"
invitees="Thea, Will, Mark, Mary"
peopleToExclude="Susan, Alberta, Frank, Larry"
coordinateSurpriseParty(caterer, host, guestOfHonor, peopleToExclude, invitees) # Noncompliant; this party will be a train wreck!
----
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
def coordinateSurpriseParty(self, hostName, guestOfHonor, caterer, invitees, peopleNotToInvite):
# ...
host="John"
guestOfHonor="Fred"
caterer="Barry"
invitees="Thea, Will, Mark, Mary"
peopleToExclude="Susan, Alberta, Frank, Larry"
coordinateSurpriseParty(caterer=caterer, hostName=host, geustOfHonor=guestOfHonor, peopleNotToInvite=peopleToExclude, invitees=invitees)
----
2021-04-28 18:08:03 +02:00
2021-09-20 15:38:42 +02:00
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== Message
Specify the argument names for these n unnamed parameters
=== Parameters
.threshold
****
----
3
----
Maximum number of unnamed arguments
****
2021-09-20 15:38:42 +02:00
endif::env-github,rspecator-view[]