rspec/rules/S3427/rule.adoc
2022-02-04 16:28:24 +00:00

23 lines
699 B
Plaintext

The rules for method resolution are complex and perhaps not properly understood by all coders. Having overloads with optional parameter values makes the matter even harder to understand.
This rule raises an issue when an overload with default parameter values is hidden by one without the optional parameters.
== Noncompliant Code Example
[source,text]
----
public class MyClass
{
void Print(string[] messages) {...}
void Print(string[] messages, string delimiter = "\n") {...} // Noncompliant; default parameter value is hidden by overload
}
// ...
MyClass myClass = new MyClass();
myClass.Print(new string[3] {"yes", "no", "maybe"}); // which version of Print will be called?
----