=== on 15 May 2019, 12:21:20 Marcel Vingerling wrote:
In my opinion this rule should ignore mandatory named arguments that have been separated in the function definition by a {color:#FF0000}``++*++``{color} in the argument list.



== Noncompliant Code Example

With a maximum number of 4 parameters:

----
def do_something(param1, param2, param3, param4, param5='default value'):
	...
----
{color:#172b4d}This is non-compliant because the function can still be called like this:{color}

----
do_something(1, 2, 3, 4, 5){code}
h2. Compliant Solution
----
def do_something(param1, param2, param3, param4, *, param5='default value'):

	...

----
In this case the {{*}} marker in the function definition dictates that the param5 parameter should always be passed as a named argument. Therefore the maximum number of positional parameters for this function is 4 and should be compliant as named parameters self document the method call and cause less brain-overload. 
 This should be compliant because the function can only be called like this:
----
do_something(1, 2, 3, 4, param5=5){code}

 


This could either be implemented in this rule or added as an additional rule, then the maximum total number of parameters can also still be validated. Maybe it makes sense to also limit the maximum number of mandatory named arguments using a rule configuration setting.


 

=== on 9 Mar 2020, 13:55:53 Nicolas Harraudeau wrote:
Hi [~sjaak],


Thank you for your suggestion, and sorry for the late reply. Could you post it on https://community.sonarsource.com/c/bug/fp/7[the community forum] please? This will enable other people to contribute to this discussion more easily.


Thanks

include::../comments-and-links.adoc[]
